vibrate 0.0.2 copy "vibrate: ^0.0.2" to clipboard
vibrate: ^0.0.2 copied to clipboard

outdatedDart 1 only

A flutter plugin to vibrate the device

example/lib/main.dart

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

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {

  bool _canVibrate = true;
  final Iterable<Duration> pauses = [
    const Duration(milliseconds: 500),
    const Duration(milliseconds: 1000),
    const Duration(milliseconds: 500),
  ];

  @override
  initState() {
    super.initState();
    init();
  }

  init() async{
    bool canVibrate = await Vibrate.canVibrate;
    setState((){_canVibrate = canVibrate;});
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(title: new Text('Plugin example app')),
        body: new Center(
          child: new Column(
            children: <Widget>[
              new ListTile(
                leading: new Icon(Icons.vibration, color: Colors.teal),
                onTap: _canVibrate ?(){Vibrate.vibrate();} : null,
                title: new Text("Vibrate")),
              new ListTile(
                  leading: new Icon(Icons.vibration, color: Colors.blue),
                  onTap: _canVibrate ?(){Vibrate.vibrateWithPauses(pauses);} : null,
                  title: new Text("Vibrate with pauses")),
            ]),
        ),
      ),
    );
  }
}
25
likes
0
pub points
81%
popularity

Publisher

unverified uploader

A flutter plugin to vibrate the device

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on vibrate