Haptic Feedback in Flutter: From HapticFeedback to vibration_flutter's Custom Patterns
Three layers of Flutter haptics — the SDK's HapticFeedback, the vibration plugin, and vibration_flutter's preset system — and when each one earns its place.
Published on • October 20, 2026
AI Assistant

Haptics are one of the cheapest quality signals in a mobile UI: a well-placed tap reads as “the system heard you,” and a missing one reads as broken. Flutter gives you three levels of haptics, and picking the wrong one is how teams end up with either flat-feeling apps or vibration code scattered everywhere. Here’s what each layer actually gives you, using vibration_flutter 1.1.0 as the top layer.
Level 1: the SDK’s HapticFeedback class
package:flutter/services.dart exposes a deliberately small API: HapticFeedback.vibrate(), selectionClick(), lightImpact(), mediumImpact(), heavyImpact(), successNotification(), warningNotification(), and errorNotification(). The docs are explicit about the design: the API is “intentionally terse since it calls default platform behavior” and is “not suitable for precise control of the system’s haptic feedback module.”
import 'package:flutter/services.dart';
Future<void> onSelectTile() async {
await HapticFeedback.selectionClick();
// ...navigate
}
That’s your whole budget for standard UI feedback — no durations, no amplitudes, no patterns. It maps to platform conventions (iOS UIImpactFeedbackStyle, Android’s standard effects), needs no permissions, and works everywhere Flutter runs. Use it for toggles, segmented controls, and button presses, and reach for a plugin only when you need timing or intensity.
Level 2: the vibration plugin for patterns and amplitude
The vibration package (3.2.1, published September 2, 2026; 941 likes and 450k downloads on pub.dev) is the low-level engine — Android, iOS, web, and OpenHarmony. Its API is where the real controls live:
import 'package:vibration/vibration.dart';
if (await Vibration.hasVibrator() ?? false) {
// Pattern alternates wait/vibrate durations in ms
await Vibration.vibrate(pattern: [0, 100, 200, 100], intensities: [0, 180]);
}
What you can verify from its docs:
Vibration.vibrate()takesduration(default 500ms),pattern(alternating wait/vibrate list),repeat(pattern index to loop, or -1),intensities(per-segment, 1–255),amplitude(1–255, -1 = platform default),sharpness(iOS only, 0.0–1.0), andpreset(about twenty named presets likeVibrationPreset.doubleBuzzandVibrationPreset.progressiveBuzz).- Capability checks:
hasVibrator(),hasAmplitudeControl()(true only on Android 8.0 Oreo and above), andhasCustomVibrationsSupport()(CoreHaptics devices on iOS). Vibration.cancel()stops an ongoing vibration.- Platform notes: Android needs
<uses-permission android:name="android.permission.VIBRATE"/>and usesVibrationEffecton Android 8+; iOS emulates patterns with 500ms vibrations on non-CoreHaptics devices.
The catch is that none of this is opinionated. You still have to invent your own “success = double buzz at medium intensity” convention and keep it consistent across the app.
Level 3: vibration_flutter’s preset layer
vibration_flutter (1.1.0, published May 28, 2026, Android and iOS; it depends on vibration: ^3.1.3 and shared_preferences: ^2.5.5) is a “game-style vibration and haptic feedback system” that wraps the engine with three ideas: a hybrid dispatcher, presets, and a persisted mute switch.
Initialize once during bootstrap:
import 'package:vibration_flutter/vibration_flutter.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await HapticService.init(); // default SharedPreferences persistence
runApp(const MyApp());
}
Then fire named events instead of raw durations. There are 12 pre-calibrated presets split into UI feedbacks (selection, lightImpact, mediumImpact, heavyImpact) and game events (success, error, levelUp, coin, heartbeat, explosion, laser, collision):
HapticService.play(HapticPreset.selection);
HapticService.play(HapticPreset.success); // double energetic tap
HapticService.play(HapticPreset.levelUp); // rising progression rumble
For bespoke sequences, HapticPattern combines millisecond timings with per-pulse amplitudes (1–255):
const customImpact = HapticPattern(
timings: [0, 150, 80, 250], // wait 0, buzz 150, wait 80, buzz 250
amplitudes: [0, 120, 0, 255], // second pulse at full power
);
await HapticService.playPattern(customImpact);
Two details make this production-viable rather than a demo. First, the global toggle: HapticService.isEnabled, toggle(), and setEnabled(false) persist automatically, so a settings switch is one line — and users on accessibility grounds expect that switch. Second, storage abstraction: implement HapticStorage to keep the flag in Hive, Isar, or secure storage instead of SharedPreferences:
class HiveHapticStorage implements HapticStorage {
@override
Future<bool> getEnabled() async =>
(await Hive.openBox('settings')).get('is_haptic_enabled', defaultValue: true) as bool;
@override
Future<void> setEnabled(bool enabled) async =>
(await Hive.openBox('settings')).put('is_haptic_enabled', enabled);
}
await HapticService.init(storage: HiveHapticStorage());
The package also ships mocking support — you can swap VibrationPlatform.instance for a mock that records vibrate() calls, so CI machines and emulators don’t throw on platform channels. The hybrid dispatcher is the claim to fame here: it picks native, crisp micro-impacts for UI selections and deeper rumble patterns for game events, rather than routing everything through one code path.
Setup and platform reality
Platform setup is thin but not zero. On Android you need the vibration permission in android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.VIBRATE"/>
On iOS, no configuration is required: standard UI impacts work out of the box, and custom patterns fall back gracefully on devices without custom haptic motors. The published platform tags for vibration_flutter are Android and iOS — so treat desktop and web as out of scope for this layer (check hasVibrator() first anyway). The repo also ships an example app with all 12 presets as tactile action cards, five interactive sliders for durations and amplitudes, and a code exporter that prints production-ready Dart for the pattern you dial in — a fast way to tune feel without rebuilding for every experiment.
Which layer should you use?
A defensible rule: HapticFeedback for standard UI affordances, vibration when you need a specific pattern or amplitude, vibration_flutter when haptics are a design system — multiple named events, a mute preference, or game feel. Before shipping, check hasVibrator() / hasAmplitudeControl() so you degrade gracefully, keep amplitude ramps restrained (a 1→255 jump in a UI list is nauseating), and always expose an off switch.