GestureDetector constructor
- Key? key,
- Widget? child,
- GestureTapDownCallback? onTapDown,
- GestureTapUpCallback? onTapUp,
- GestureTapCallback? onTap,
- GestureTapCancelCallback? onTapCancel,
- GestureTapCallback? onSecondaryTap,
- GestureTapDownCallback? onSecondaryTapDown,
- GestureTapUpCallback? onSecondaryTapUp,
- GestureTapCancelCallback? onSecondaryTapCancel,
- GestureTapDownCallback? onTertiaryTapDown,
- GestureTapUpCallback? onTertiaryTapUp,
- GestureTapCancelCallback? onTertiaryTapCancel,
- GestureTapDownCallback? onDoubleTapDown,
- GestureTapCallback? onDoubleTap,
- GestureTapCancelCallback? onDoubleTapCancel,
- GestureLongPressDownCallback? onLongPressDown,
- GestureLongPressCancelCallback? onLongPressCancel,
- GestureLongPressCallback? onLongPress,
- GestureLongPressStartCallback? onLongPressStart,
- GestureLongPressMoveUpdateCallback? onLongPressMoveUpdate,
- GestureLongPressUpCallback? onLongPressUp,
- GestureLongPressEndCallback? onLongPressEnd,
- GestureLongPressDownCallback? onSecondaryLongPressDown,
- GestureLongPressCancelCallback? onSecondaryLongPressCancel,
- GestureLongPressCallback? onSecondaryLongPress,
- GestureLongPressStartCallback? onSecondaryLongPressStart,
- GestureLongPressMoveUpdateCallback? onSecondaryLongPressMoveUpdate,
- GestureLongPressUpCallback? onSecondaryLongPressUp,
- GestureLongPressEndCallback? onSecondaryLongPressEnd,
- GestureLongPressDownCallback? onTertiaryLongPressDown,
- GestureLongPressCancelCallback? onTertiaryLongPressCancel,
- GestureLongPressCallback? onTertiaryLongPress,
- GestureLongPressStartCallback? onTertiaryLongPressStart,
- GestureLongPressMoveUpdateCallback? onTertiaryLongPressMoveUpdate,
- GestureLongPressUpCallback? onTertiaryLongPressUp,
- GestureLongPressEndCallback? onTertiaryLongPressEnd,
- GestureDragDownCallback? onVerticalDragDown,
- GestureDragStartCallback? onVerticalDragStart,
- GestureDragUpdateCallback? onVerticalDragUpdate,
- GestureDragEndCallback? onVerticalDragEnd,
- GestureDragCancelCallback? onVerticalDragCancel,
- GestureDragDownCallback? onHorizontalDragDown,
- GestureDragStartCallback? onHorizontalDragStart,
- GestureDragUpdateCallback? onHorizontalDragUpdate,
- GestureDragEndCallback? onHorizontalDragEnd,
- GestureDragCancelCallback? onHorizontalDragCancel,
- GestureForcePressStartCallback? onForcePressStart,
- GestureForcePressPeakCallback? onForcePressPeak,
- GestureForcePressUpdateCallback? onForcePressUpdate,
- GestureForcePressEndCallback? onForcePressEnd,
- GestureDragDownCallback? onPanDown,
- GestureDragStartCallback? onPanStart,
- GestureDragUpdateCallback? onPanUpdate,
- GestureDragEndCallback? onPanEnd,
- GestureDragCancelCallback? onPanCancel,
- GestureScaleStartCallback? onScaleStart,
- GestureScaleUpdateCallback? onScaleUpdate,
- GestureScaleEndCallback? onScaleEnd,
- HitTestBehavior? behavior,
- bool excludeFromSemantics = false,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- bool trackpadScrollCausesScale = false,
- Offset trackpadScrollToScaleFactor = kDefaultTrackpadScrollToScaleFactor,
- Set<
PointerDeviceKind> ? supportedDevices,
Creates a widget that detects gestures.
Pan and scale callbacks cannot be used simultaneously because scale is a superset of pan. Use the scale callbacks instead.
Horizontal and vertical drag callbacks cannot be used simultaneously because a combination of a horizontal and vertical drag is a pan. Use the pan callbacks instead.
By default, gesture detectors contribute semantic information to the tree that is used by assistive technology.
Implementation
GestureDetector({
super.key,
this.child,
this.onTapDown,
this.onTapUp,
this.onTap,
this.onTapCancel,
this.onSecondaryTap,
this.onSecondaryTapDown,
this.onSecondaryTapUp,
this.onSecondaryTapCancel,
this.onTertiaryTapDown,
this.onTertiaryTapUp,
this.onTertiaryTapCancel,
this.onDoubleTapDown,
this.onDoubleTap,
this.onDoubleTapCancel,
this.onLongPressDown,
this.onLongPressCancel,
this.onLongPress,
this.onLongPressStart,
this.onLongPressMoveUpdate,
this.onLongPressUp,
this.onLongPressEnd,
this.onSecondaryLongPressDown,
this.onSecondaryLongPressCancel,
this.onSecondaryLongPress,
this.onSecondaryLongPressStart,
this.onSecondaryLongPressMoveUpdate,
this.onSecondaryLongPressUp,
this.onSecondaryLongPressEnd,
this.onTertiaryLongPressDown,
this.onTertiaryLongPressCancel,
this.onTertiaryLongPress,
this.onTertiaryLongPressStart,
this.onTertiaryLongPressMoveUpdate,
this.onTertiaryLongPressUp,
this.onTertiaryLongPressEnd,
this.onVerticalDragDown,
this.onVerticalDragStart,
this.onVerticalDragUpdate,
this.onVerticalDragEnd,
this.onVerticalDragCancel,
this.onHorizontalDragDown,
this.onHorizontalDragStart,
this.onHorizontalDragUpdate,
this.onHorizontalDragEnd,
this.onHorizontalDragCancel,
this.onForcePressStart,
this.onForcePressPeak,
this.onForcePressUpdate,
this.onForcePressEnd,
this.onPanDown,
this.onPanStart,
this.onPanUpdate,
this.onPanEnd,
this.onPanCancel,
this.onScaleStart,
this.onScaleUpdate,
this.onScaleEnd,
this.behavior,
this.excludeFromSemantics = false,
this.dragStartBehavior = DragStartBehavior.start,
this.trackpadScrollCausesScale = false,
this.trackpadScrollToScaleFactor = kDefaultTrackpadScrollToScaleFactor,
this.supportedDevices,
}) : assert(() {
final bool haveVerticalDrag = onVerticalDragStart != null || onVerticalDragUpdate != null || onVerticalDragEnd != null;
final bool haveHorizontalDrag = onHorizontalDragStart != null || onHorizontalDragUpdate != null || onHorizontalDragEnd != null;
final bool havePan = onPanStart != null || onPanUpdate != null || onPanEnd != null;
final bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null;
if (havePan || haveScale) {
if (havePan && haveScale) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('Incorrect GestureDetector arguments.'),
ErrorDescription(
'Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan.',
),
ErrorHint('Just use the scale gesture recognizer.'),
]);
}
final String recognizer = havePan ? 'pan' : 'scale';
if (haveVerticalDrag && haveHorizontalDrag) {
throw FlutterError(
'Incorrect GestureDetector arguments.\n'
'Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a $recognizer gesture recognizer '
'will result in the $recognizer gesture recognizer being ignored, since the other two will catch all drags.',
);
}
}
return true;
}());