Flutter: How to use HapticFeedback

Ymi_Yugy picture Ymi_Yugy · Jun 1, 2019 · Viewed 18.5k times · Source

I have imported

import 'package:flutter/services.dart';

and then called

HapticFeedback.lightImpact();

nothing happens. What do I need to do to get it working? I am testing with the latest Flutter version 1.6.6 on a Galaxy S8 running Android 9.0

Answer

Sergey picture Sergey · Sep 12, 2019

Please make sure that Vibration feedback is enabled on the android device, and make sure to add

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

to the AndroidManifest.xml. See more info here: https://github.com/flutter/flutter/issues/33750