<p>In this article, I'm going to share you an example of how to handle gestures in Flutter. This is how the final output is going to look. ; font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre-wrap; background-color: rgb(40, 44, 52);](onTap, color: rgb(187, 187, 187); font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre-wrap; background-color: rgb(40, 44, 52);](onDoubleTap and color: rgb(187, 187, 187); font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre-wrap; background-color: rgb(40, 44, 52);](onLongPressfont-size: 1rem;]( gestures. Check out <a href="https://docs.flutter.io/flutter/widgets/GestureDetector-class.html">https://docs.flutter.io/flutter/widgets/GestureDetector-class.html</a> for more properties. Here is the full code from main.dart file. You just need to create a flutter program and replace the code in main.dart file with below code.color: rgb(187, 187, 187); background-color: rgb(40, 44, 52); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;](color: #c678dd;](import color: #98c379;]('package:flutter/material.dart'; color: #c678dd;](void color: #61afef;](main() { color: #61afef;](runApp(color: #e5c07b;](MaterialApp(titlecolor: #c678dd;](: color: #98c379;]("Gestures Demo",homecolor: #c678dd;](: color: #e5c07b;](MyApp(),));} color: #c678dd;](class color: #e5c07b;](MyApp color: #c678dd;](extends color: #e5c07b;](StatefulWidget { color: #c678dd;](@override color: #e5c07b;](_MyAppState color: #61afef;](createState() => color: #e5c07b;](_MyAppState();} color: #c678dd;](class color: #e5c07b;](_MyAppState color: #c678dd;](extends color: #e5c07b;](Statecolor: #56b6c2;]( { color: #c678dd;](var _action color: #56b6c2;](= color: #98c379;]("Waiting for an action"; color: #c678dd;](@override color: #e5c07b;](Widget color: #61afef;](build(color: #e5c07b;](BuildContext context) { color: #c678dd;](return color: #e5c07b;](Scaffold(appBarcolor: #c678dd;](: color: #e5c07b;](AppBar(titlecolor: #c678dd;](: color: #e5c07b;](Text(color: #98c379;]("Gestures Demo"),),bodycolor: #c678dd;](: color: #e5c07b;](Center(childcolor: #c678dd;](: color: #e5c07b;](Column(childrencolor: #c678dd;](: color: #56b6c2;]([ color: #e5c07b;](Padding(paddingcolor: #c678dd;](: color: #e5c07b;](EdgeInsets.color: #61afef;](all(color: #d19a66;](50.0),), color: #e5c07b;](Text( color: #98c379;]("$color: #e06c75;font-style: italic;](_actioncolor: #98c379;](",), color: #e5c07b;](GestureDetector(onTapcolor: #c678dd;](: () { color: #61afef;](setState(() );},onDoubleTapcolor: #c678dd;](: () { color: #61afef;](setState(() {_action color: #56b6c2;](= color: #98c379;]("Double Tapped";});},onLongPresscolor: #c678dd;](: () { color: #61afef;](setState(() {_action color: #56b6c2;](= color: #98c379;]("Log Pressed";});},childcolor: #c678dd;](: color: #e5c07b;](Container(heightcolor: #c678dd;](: color: #d19a66;](40.0,paddingcolor: #c678dd;](: color: #e5c07b;](EdgeInsets.color: #61afef;](all(color: #d19a66;](10.0),margincolor: #c678dd;](: color: #e5c07b;](EdgeInsets.color: #61afef;](symmetric(verticalcolor: #c678dd;](: color: #d19a66;](28.0),decorationcolor: #c678dd;](: color: #e5c07b;](BoxDecoration(borderRadiuscolor: #c678dd;](: color: #e5c07b;](BorderRadius.color: #61afef;](circular(color: #d19a66;](5.0),colorcolor: #c678dd;](: color: #e5c07b;](Colors.lightGreen,),childcolor: #c678dd;](: color: #e5c07b;](Text(color: #98c379;]("Do something here"),),),],)),);}} color: rgb(187, 187, 187); background-color: rgb(40, 44, 52); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre-wrap;](</p> <p>Hope this is helpful. Thanks,Srikanth</p>
Handling gestures in Flutter
This Article is posted by seven.srikanth at 12/6/2018 2:57:16 AM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags: Handling gestures in Flutter; handle onTap, onDoubleTap and onLongPress gestures in flutter;
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter