GestureDetector constructor

GestureDetector(
  1. {Key key,
  2. Widget child,
  3. void onTapDown(
    1. TapDownDetails details
    ),
  4. void onTapUp(
    1. TapUpDetails details
    ),
  5. GestureTapCallback onTap,
  6. GestureTapCancelCallback onTapCancel,
  7. GestureTapCallback onSecondaryTap,
  8. void onSecondaryTapDown(
    1. TapDownDetails details
    ),
  9. void onSecondaryTapUp(
    1. TapUpDetails details
    ),
  10. GestureTapCancelCallback onSecondaryTapCancel,
  11. void onTertiaryTapDown(
    1. TapDownDetails details
    ),
  12. void onTertiaryTapUp(
    1. TapUpDetails details
    ),
  13. GestureTapCancelCallback onTertiaryTapCancel,
  14. void onDoubleTapDown(
    1. TapDownDetails details
    ),
  15. GestureTapCallback onDoubleTap,
  16. GestureTapCancelCallback onDoubleTapCancel,
  17. GestureLongPressCallback onLongPress,
  18. void onLongPressStart(
    1. LongPressStartDetails details
    ),
  19. void onLongPressMoveUpdate(
    1. LongPressMoveUpdateDetails details
    ),
  20. GestureLongPressUpCallback onLongPressUp,
  21. void onLongPressEnd(
    1. LongPressEndDetails details
    ),
  22. GestureLongPressCallback onSecondaryLongPress,
  23. void onSecondaryLongPressStart(
    1. LongPressStartDetails details
    ),
  24. void onSecondaryLongPressMoveUpdate(
    1. LongPressMoveUpdateDetails details
    ),
  25. GestureLongPressUpCallback onSecondaryLongPressUp,
  26. void onSecondaryLongPressEnd(
    1. LongPressEndDetails details
    ),
  27. void onVerticalDragDown(
    1. DragDownDetails details
    ),
  28. void onVerticalDragStart(
    1. DragStartDetails details
    ),
  29. void onVerticalDragUpdate(
    1. DragUpdateDetails details
    ),
  30. void onVerticalDragEnd(
    1. DragEndDetails details
    ),
  31. GestureDragCancelCallback onVerticalDragCancel,
  32. void onHorizontalDragDown(
    1. DragDownDetails details
    ),
  33. void onHorizontalDragStart(
    1. DragStartDetails details
    ),
  34. void onHorizontalDragUpdate(
    1. DragUpdateDetails details
    ),
  35. void onHorizontalDragEnd(
    1. DragEndDetails details
    ),
  36. GestureDragCancelCallback onHorizontalDragCancel,
  37. void onForcePressStart(
    1. ForcePressDetails details
    ),
  38. void onForcePressPeak(
    1. ForcePressDetails details
    ),
  39. void onForcePressUpdate(
    1. ForcePressDetails details
    ),
  40. void onForcePressEnd(
    1. ForcePressDetails details
    ),
  41. void onPanDown(
    1. DragDownDetails details
    ),
  42. void onPanStart(
    1. DragStartDetails details
    ),
  43. void onPanUpdate(
    1. DragUpdateDetails details
    ),
  44. void onPanEnd(
    1. DragEndDetails details
    ),
  45. GestureDragCancelCallback onPanCancel,
  46. void onScaleStart(
    1. ScaleStartDetails details
    ),
  47. void onScaleUpdate(
    1. ScaleUpdateDetails details
    ),
  48. void onScaleEnd(
    1. ScaleEndDetails details
    ),
  49. HitTestBehavior behavior,
  50. bool excludeFromSemantics: false,
  51. DragStartBehavior dragStartBehavior: DragStartBehavior.start}
)

Creates a widget that detects gestures.

Pan and scale callbacks cannot be used simultaneously because scale is a superset of pan. Simply 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. Simply use the pan callbacks instead.

By default, gesture detectors contribute semantic information to the tree that is used by assistive technology.

Implementation

GestureDetector({
  Key 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.onLongPress,
  this.onLongPressStart,
  this.onLongPressMoveUpdate,
  this.onLongPressUp,
  this.onLongPressEnd,
  this.onSecondaryLongPress,
  this.onSecondaryLongPressStart,
  this.onSecondaryLongPressMoveUpdate,
  this.onSecondaryLongPressUp,
  this.onSecondaryLongPressEnd,
  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,
}) : assert(excludeFromSemantics != null),
     assert(dragStartBehavior != null),
     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;
     }()),
     super(key: key);