forLongPress method Null safety
- BuildContext context
Provides platform-specific feedback for a long press.
On Android the platform-typical vibration is triggered. On iOS this is a no-op as that platform usually doesn't provide feedback for long presses.
See also:
- wrapForLongPress to trigger platform-specific feedback before executing a GestureLongPressCallback.
Implementation
static Future<void> forLongPress(BuildContext context) {
context.findRenderObject()!.sendSemanticsEvent(const LongPressSemanticsEvent());
switch (_platform(context)) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
return HapticFeedback.vibrate();
case TargetPlatform.iOS:
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
return Future<void>.value();
}
}