LongPressGestureRecognizer constructor Null safety

  1. {Duration? duration,
  2. double? postAcceptSlopTolerance = null,
  3. @Deprecated('Migrate to supportedDevices. ' 'This feature was deprecated after v2.3.0-1.0.pre.') PointerDeviceKind? kind,
  4. Set<PointerDeviceKind>? supportedDevices,
  5. Object? debugOwner}

Creates a long-press gesture recognizer.

Consider assigning the onLongPressStart callback after creating this object.

The postAcceptSlopTolerance argument can be used to specify a maximum allowed distance for the gesture to deviate from the starting point once the long press has triggered. If the gesture deviates past that point, subsequent callbacks (onLongPressMoveUpdate, onLongPressUp, onLongPressEnd) will stop. Defaults to null, which means the gesture can be moved without limit once the long press is accepted.

The duration argument can be used to overwrite the default duration after which the long press will be recognized.

It's possible to limit this recognizer to a specific set of PointerDeviceKinds by providing the optional supportedDevices argument. If supportedDevices is null, the recognizer will accept pointer events from all device kinds.


  Duration? duration,
  super.postAcceptSlopTolerance = null,
    'Migrate to supportedDevices. '
    'This feature was deprecated after v2.3.0-1.0.pre.',
}) : super(
       deadline: duration ?? kLongPressTimeout,