wrapForLongPress static method

GestureLongPressCallback? wrapForLongPress(
  1. GestureLongPressCallback? callback,
  2. BuildContext context
)

Wraps a GestureLongPressCallback to provide platform specific feedback for a long press before the provided callback is executed.

On Android the platform-typical vibration is triggered. On iOS a heavy-impact haptic feedback is triggered alongside the click system sound, which was observed to be the default behavior on a physical iPhone 15 Pro running iOS version 17.5.

See also:

Implementation

static GestureLongPressCallback? wrapForLongPress(GestureLongPressCallback? callback, BuildContext context) {
  if (callback == null) {
    return null;
  }
  return () {
    Feedback.forLongPress(context);
    callback();
  };
}