Flutter Haptic Feedback: Make users feel your App

There is always a gap between the digital and real worlds🌐🌍. No matter how advanced the technology is, we always miss the feeling of reality 😔. Flutter Haptic feedback is one way to bridge the gap between these two realms 🤝.

Providing users with physical feedback, such as 🔊 audio or 📳 vibration, creates a more intuitive and accessible interaction and improves the user experience.

Let’s make users feel flutter app:

Well, flutter always has some simplified solution to achieve anything. Nothing different this time; Flutter has package haptic_feedback that emulates the haptic patterns and makes it consistent across the platforms 🚀💻📱.

  • Install the package using the below command.
flutter pub add haptic_feedback
  • Now we’ve to check if the vibration is enabled in the device. Remember, not all devices support haptic feedback/vibration. It is always recommended to have a fallback.
final canVibrate = await Haptics.canVibrate();
  • If this device supports vibration, all you need to do is to call the await Haptics.vibrate(HapticsType.success); This package provides different types of Haptics based on the action, making it consistent with the other apps on the device.
await Haptics.vibrate(HapticsType.success);
await Haptics.vibrate(HapticsType.warning);
await Haptics.vibrate(HapticsType.error);

await Haptics.vibrate(HapticsType.light);
await Haptics.vibrate(HapticsType.medium);
await Haptics.vibrate(HapticsType.heavy);

await Haptics.vibrate(HapticsType.rigid);
await Haptics.vibrate(HapticsType.soft);

await Haptics.vibrate(HapticsType.selection);
  • When integrating the haptic_feedback plugin into your Flutter project, necessary VIBRATE permission is automatically imported into the final merged AndroidManifest.xml due to the permission being declared in the plugin’s manifest.

Is this everything about flutter haptic feedback..?

Of course not; there is a lot to it. I plan to cover all these in the upcoming stories and never miss an update from Flutter Simplified.

Follow us on Instagram.

Share this article
Shareable URL
Comments 1
Leave a Reply

Your email address will not be published. Required fields are marked *

Read next
Subscribe to our newsletter