vibrate 0.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 47

Vibrate #

pub package A Flutter plugin to vibrate the device.

Usage #

To use this plugin, add vibrate as a dependency in your pubspec.yaml file.

Make sure you add the following permissions to your Android Manifest

<uses-permission android:name="android.permission.VIBRATE" />

Example #

// Import package
import 'package:vibrate/vibrate.dart';

// Check if the device can vibrate
bool canVibrate = await Vibrate.canVibrate;

// Vibrate
// Vibration duration is a constant 500ms because 
// it cannot be set to a specific duration on iOS.
Vibrate.vibrate()

// Vibrate with pauses between each vibration
final Iterable<Duration> pauses = [
    const Duration(milliseconds: 500),
    const Duration(milliseconds: 1000),
    const Duration(milliseconds: 500),
];
// vibrate - sleep 0.5s - vibrate - sleep 1s - vibrate - sleep 0.5s - vibrate
Vibrate.vibrate(pauses);

[0.0.2] - January 26th, 2018.

  • added vibrateWithPauses(Iterable<Duration> pauses)

[0.0.1] - January 24th, 2018.

  • vibrate() and canVibrate() implemented on iOS and Android

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")),
            ]),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  vibrate: ^0.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:vibrate/vibrate.dart';
  
Version Uploaded Documentation Archive
0.0.4 Aug 22, 2018 Go to the documentation of vibrate 0.0.4 Download vibrate 0.0.4 archive
0.0.3 Jul 10, 2018 Go to the documentation of vibrate 0.0.3 Download vibrate 0.0.3 archive
0.0.2 Jan 26, 2018 Go to the documentation of vibrate 0.0.2 Download vibrate 0.0.2 archive
0.0.1 Jan 24, 2018 Go to the documentation of vibrate 0.0.1 Download vibrate 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
94
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
47
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.