Skip to content

A flutter plugin for device vibration and haptic feedback.

License

Notifications You must be signed in to change notification settings

miguelcmedeiros/flutter_vibrate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vibrate

pub package

A Flutter plugin to vibrate the device. This uses all the current Haptic Feedback APIs from Apple and provides similar feedback on Android.

Usage

To use this plugin, add flutter_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"/>

Usage

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

Vibration

// 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.vibrateWithPauses(pauses);

Haptic Feedback

// Choose from any of these available methods
enum FeedbackType {
  success,
  error,
  warning,
  selection,
  impact,
  heavy,
  medium,
  light
}

var _type = FeedbackType.impact;
Vibrate.feedback(_type);

Documentation

Android

https://developer.android.com/reference/android/view/HapticFeedbackConstants

iOS

https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/feedback/

About

A flutter plugin for device vibration and haptic feedback.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 34.6%
  • Swift 23.1%
  • Ruby 22.4%
  • Java 18.0%
  • Objective-C 1.9%