GestureDetector widget in Stac allows you to detect various gestures and user interactions within your application. It wraps Flutter’s native GestureDetector widget, providing a JSON-based interface to handle touch events, taps, drags, and more.
Usage
To use a GestureDetector in your Stac, specify the widget type as “gestureDetector” and provide a child widget along with any gesture callbacks you want to handle.Properties
Child Widget
| Property | Type | Description |
|---|---|---|
child | StacWidget | The widget that will respond to gestures |
Tap Gestures
| Property | Type | Description |
|---|---|---|
onTapDown | StacAction | Called when a pointer contacts the screen |
onTapUp | StacAction | Called when a pointer stops contacting the screen |
onTap | StacAction | Called when a tap occurs |
onTapCancel | StacAction | Called when the tap is canceled |
onDoubleTapDown | StacAction | Called when a pointer contacts the screen in a potential double tap |
onDoubleTap | StacAction | Called when a double tap occurs |
onDoubleTapCancel | StacAction | Called when the double tap is canceled |
Secondary and Tertiary Tap Gestures
| Property | Type | Description |
|---|---|---|
onSecondaryTap | StacAction | Called when a secondary tap occurs (e.g., right-click) |
onSecondaryTapDown | StacAction | Called when a secondary pointer contacts the screen |
onSecondaryTapUp | StacAction | Called when a secondary pointer stops contacting the screen |
onSecondaryTapCancel | StacAction | Called when the secondary tap is canceled |
onTertiaryTapDown | StacAction | Called when a tertiary pointer contacts the screen |
onTertiaryTapUp | StacAction | Called when a tertiary pointer stops contacting the screen |
onTertiaryTapCancel | StacAction | Called when the tertiary tap is canceled |
Long Press Gestures
| Property | Type | Description |
|---|---|---|
onLongPressDown | StacAction | Called when a pointer contacts the screen in a potential long press |
onLongPressCancel | StacAction | Called when the long press is canceled |
onLongPress | StacAction | Called when a long press occurs |
onLongPressStart | StacAction | Called when a long press starts |
onLongPressMoveUpdate | StacAction | Called when a long press move update occurs |
onLongPressUp | StacAction | Called when a long press up occurs |
onLongPressEnd | StacAction | Called when a long press ends |
Secondary and Tertiary Long Press Gestures
| Property | Type | Description |
|---|---|---|
onSecondaryLongPressDown | StacAction | Called when a secondary pointer contacts the screen in a potential long press |
onSecondaryLongPressCancel | StacAction | Called when the secondary long press is canceled |
onSecondaryLongPress | StacAction | Called when a secondary long press occurs |
onSecondaryLongPressStart | StacAction | Called when a secondary long press starts |
onSecondaryLongPressMoveUpdate | StacAction | Called when a secondary long press move update occurs |
onSecondaryLongPressUp | StacAction | Called when a secondary long press up occurs |
onSecondaryLongPressEnd | StacAction | Called when a secondary long press ends |
onTertiaryLongPressDown | StacAction | Called when a tertiary pointer contacts the screen in a potential long press |
onTertiaryLongPressCancel | StacAction | Called when the tertiary long press is canceled |
onTertiaryLongPress | StacAction | Called when a tertiary long press occurs |
onTertiaryLongPressStart | StacAction | Called when a tertiary long press starts |
onTertiaryLongPressMoveUpdate | StacAction | Called when a tertiary long press move update occurs |
onTertiaryLongPressUp | StacAction | Called when a tertiary long press up occurs |
onTertiaryLongPressEnd | StacAction | Called when a tertiary long press ends |
Drag Gestures
| Property | Type | Description |
|---|---|---|
onVerticalDragDown | StacAction | Called when a pointer contacts the screen and might begin a vertical drag |
onVerticalDragStart | StacAction | Called when a pointer starts a vertical drag |
onVerticalDragUpdate | StacAction | Called when a pointer updates a vertical drag |
onVerticalDragEnd | StacAction | Called when a pointer ends a vertical drag |
onVerticalDragCancel | StacAction | Called when the vertical drag is canceled |
onHorizontalDragDown | StacAction | Called when a pointer contacts the screen and might begin a horizontal drag |
onHorizontalDragStart | StacAction | Called when a pointer starts a horizontal drag |
onHorizontalDragUpdate | StacAction | Called when a pointer updates a horizontal drag |
onHorizontalDragEnd | StacAction | Called when a pointer ends a horizontal drag |
onHorizontalDragCancel | StacAction | Called when the horizontal drag is canceled |
Force Press Gestures
| Property | Type | Description |
|---|---|---|
onForcePressStart | StacAction | Called when a force press starts |
onForcePressPeak | StacAction | Called when a force press reaches its peak force |
onForcePressUpdate | StacAction | Called when a force press updates |
onForcePressEnd | StacAction | Called when a force press ends |
Other Properties
| Property | Type | Default | Description |
|---|---|---|---|
excludeFromSemantics | bool | false | Whether to exclude the gestures from the semantics tree |
dragStartBehavior | StacDragStartBehavior | start | Determines when a drag formally starts |