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,
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}
8
likes
150
points
168
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter Plugin for calling mobile native Haptic feature

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_haptic