![]() |
VOOZH | about |
Gestures are used to interact with an application. It is generally used in touch-based devices to physically interact with the application. It can be as simple as a single tap on the screen to a more complex physical interaction like swiping in a specific direction to scrolling down an application. It is heavily used in gaming and more or less every application requires it to function as devices turn more touch-based than ever. In this article, we will discuss them in detail.
Some widely used gestures are mentioned here :
The GestureDetector widget in flutter is used to detect physical interaction with the application on the UI. If a widget is supposed to experience a gesture, it is kept inside the GestureDetector widget. The same widget catches the gesture and returns the appropriate action or response.
GestureDetector GestureDetector({
Key? key,
Widget? child,
void Function(TapDownDetails)? onTapDown,
void Function(TapUpDetails)? onTapUp,
void Function()? onTap,
void Function()? onTapCancel,
void Function()? onSecondaryTap,
void Function(TapDownDetails)? onSecondaryTapDown,
void Function(TapUpDetails)? onSecondaryTapUp,
void Function()? onSecondaryTapCancel,
void Function(TapDownDetails)? onTertiaryTapDown,
void Function(TapUpDetails)? onTertiaryTapUp,
void Function()? onTertiaryTapCancel,
void Function(TapDownDetails)? onDoubleTapDown,
void Function()? onDoubleTap,
void Function()? onDoubleTapCancel,
void Function(LongPressDownDetails)? onLongPressDown,
void Function()? onLongPressCancel,
void Function()? onLongPress,
.........
})
Property | Description |
|---|---|
child | The widget below this widget in the tree. |
onTapDown | A pointer that might cause a tap with a primary button has contacted the screen at a particular location. |
onTapUp | A pointer that will trigger a tap with a primary button has stopped contacting the screen at a particular location. |
onTap | A tap with a primary button has occurred. |
onTapCancel | The pointer that previously triggered onTapDown will not end up causing a tap. |
onDoubleTap | The user has tapped the screen with a primary button at the same location twice in quick succession. |
onLongPress | Called when a long press gesture with a primary button has been recognized. |
main.dart:
To know more about Container and SnackBar in flutter refer this articles respectively: Container class in Flutter and Flutter – Snackbar.
Output: