vibration 1.0.1
vibration: ^1.0.1 copied to clipboard

outdated

A plugin for handling Vibration API on iOS and Android devices

Vibration #

Build Status

A plugin for handling Vibration API on iOS and Android devices. API docs.

Getting Started #

  1. Add vibration to the dependencies section of pubspec.yaml.

     dependencies:
       vibration: 1.0.1
    
  2. Import package:

     import 'package:vibration/vibration.dart';
    

Methods #

hasVibrator #

Check if the target device has vibration capabilities.

if (Vibration.hasVibrator()) {
    Vibration.vibrate();
}

vibrate #

With specific duration (for example, 1 second):

Vibration.vibrate(duration: 1000);

Default duration is 500ms.

With pattern (wait 500ms, vibrate 1s, waint 500ms):

Vibration.vibrate(pattern: [500, 1000, 500]);

cancel #

Stop ongoing vibration.

Vibration.cancel();

Android #

The VIBRATE permission is required in AndroidManifest.xml.

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

Supports vibration with duration and pattern. On Android 8 (Oreo) and above, uses the VibrationEffect class. For the rest of the usage instructions, see Vibrator class documentation.

iOS #

Only supports singular vibrations with 500ms duration.

267
likes
0
pub points
98%
popularity

A plugin for handling Vibration API on iOS and Android devices

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, flutter_test

More

Packages that depend on vibration