flutter_haptic 0.0.3 copy "flutter_haptic: ^0.0.3" to clipboard
flutter_haptic: ^0.0.3 copied to clipboard

Flutter Plugin for calling mobile native Haptic feature

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_haptic/haptic.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Haptic Plugin Example'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(20),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              _horizontallyStretchedButton(context, 'on Success', () {
                Haptic.onSuccess();
              }),
              _horizontallyStretchedButton(context, 'on Failure', () {
                Haptic.onFailure();
              }),
              _horizontallyStretchedButton(context, 'on Selection', () {
                Haptic.onSelection();
              }),
            ],
          ),
        ),
      ),
    );
  }

  Widget _horizontallyStretchedButton(BuildContext context, String title, VoidCallback onPressed) {
    return Row(
      children: [
        Expanded(
          child: SizedBox(
            height: 44,
            child: MaterialButton(
              color: Theme.of(context).primaryColor,
              onPressed: onPressed,
              child: Text(
                title,
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 16,
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}
7
likes
120
pub points
66%
popularity

Publisher

unverified uploader

Flutter Plugin for calling mobile native Haptic feature

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_haptic