vibrate static method
Future<void>
vibrate(
- HapticsType type, {
- HapticsUsage? usage,
- bool useAndroidHapticConstants = false,
Performs haptic feedback of HapticsType on the device. Performs nothing if the platform is not supported.
Provide usage to influence how Android routes the vibration when running
on API level 33 or later (for example, HapticsUsage.media for breathing
exercises). The value is ignored on older Android versions and on iOS.
On Android, set useAndroidHapticConstants to true to
use the platform HapticFeedbackConstants (e.g., CONFIRM, REJECT,
VIRTUAL_KEY) when available. Set to false to use custom vibration
primitives instead, which more closely mirror the iOS patterns.
Implementation
static Future<void> vibrate(
HapticsType type, {
HapticsUsage? usage,
bool useAndroidHapticConstants = false,
}) async {
if (!isPlatformSupported) {
return;
}
return HapticFeedbackPlatform.instance.vibrate(
type,
usage: usage,
useAndroidHapticConstants: useAndroidHapticConstants,
);
}