Haptic Feedback in Flutter, Types and Implementation
Playing haptics can engage people’s sense of touch and bring their familiarity with the physical world into your app. You might have experience a bit of an impact or vibration. In certain apps while interacting with some of its components.
This can be achieved in Flutter with the use of the HapticFeedback class.
HapticFeedback is a class in Flutter that enables haptic feedback interface on the device.
There are different impact intensities in the HaptickFeedback class:
- heavyImpact() - feedback corresponding with the heavy mass impact
- lightImpact() - light haptic feedback to denote an action
- mediumImpact() - a medium feedback with a normal haptic response
- selectionClick() - Provides a haptic feedback corresponding a collision impact with a medium mass.
- vibrate() - gives the user a system vibration impact
We can use the HapticFeedback with button taps, bottomsheet triggers, alert dialogs or even pull to refresh actions.
We will provide a lightImpact haptic when the user taps a widget.
We can also customize the feedback experience by enclosing the user interface by enclosing the user interface inside a Listener Widget.
The Listener Widget in flutter provides callbacks in response to pointer events like:
Adding feedbacks on user touch and release, to give a more of an intuitive experience:
For more information check out: