How to implement vibration with Flutter for both Android and iOS?

Miha picture Miha · Jun 2, 2019 · Viewed 11.7k times · Source

Using Flutter I am trying to implement vibration on a button click.

I find it surprisingly difficult to be honest. I've tried using the following packages unsuccessfully: vibration and vibrate but they just do not vibrate (talking here about the real devices not emulators/simulators).

Is there a guide with clear examples on how to implement vibration on iOS and Android devices with Flutter?

Thanks, Mihai

Answer

Miha picture Miha · Jun 7, 2019

Found a way using HapticFeedback.vibrate(). It works for both iOS and Android. See more details with code example and other settings on this [post][1]: Flutter: How to use HapticFeedback