haptics 0.0.6 copy "haptics: ^0.0.6" to clipboard
haptics: ^0.0.6 copied to clipboard

discontinued

Haptic feedback cross platform.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:haptics/haptics.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Haptic Feedback example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HapticsDemo(title: 'Haptic Feedback example'),
    );
  }
}

class HapticsDemo extends StatefulWidget {
  const HapticsDemo({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<HapticsDemo> createState() => _HapticsDemoState();
}

class _HapticsDemoState extends State<HapticsDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ListView(
        children: [
          TextButton(
              onPressed: () async {
                await Haptics.feedback(HapticLevel.success);
              },
              child: Text('Success haptic feedback')),
          Divider(),
          TextButton(
              onPressed: () async {
                await Haptics.feedback(HapticLevel.error);
              },
              child: Text('Error haptic feedback')),
          Divider(),
          TextButton(
              onPressed: () async {
                await Haptics.feedback(HapticLevel.warning);
              },
              child: Text('Warning haptic feedback')),
          Divider(),
          TextButton(
              onPressed: () async {
                await Haptics.feedback(HapticLevel.heavy);
              },
              child: Text('Heavy haptic feedback')),
          Divider(),
          TextButton(
              onPressed: () async {
                await Haptics.feedback(HapticLevel.medium);
              },
              child: Text('Medium haptic feedback')),
          Divider(),
          TextButton(
              onPressed: () async {
                await Haptics.feedback(HapticLevel.light);
              },
              child: Text('Light haptic feedback')),
          Divider(),
        ],
      ),
    );
  }
}
0
likes
140
points
12
downloads

Publisher

verified publisherbenhaim.app

Weekly Downloads

Haptic feedback cross platform.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on haptics

Packages that implement haptics