import 'package:flutter/material.dart';
void main(){
runApp(GestureSwipeApp());
}
class GestureSwipeApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
title:'Swipe Detector',
home:SwipePage(),
);
}
}
class SwipePage extends StatefulWidget{
@override
_SwipePageState createState()=>_SwipePageState();
}
class _SwipePageState extends State<SwipePage>{
String _gestureText='Swipe horizontally or double tap';
void _onHorizontalDragEnd(DragEndDetails details){
setState((){
_gestureText='Swipe Detected';
});
}
void _onDoubleTap(){
setState((){
_gestureText='Double Tap Detected';
});
}
@override
Widget build(BuildContext context){
return Scaffold(
appBar:AppBar(title:Text('Gesture Detector')),
body:Center(
child:GestureDetector(
onHorizontalDragEnd: _onHorizontalDragEnd,
onDoubleTap:_onDoubleTap,
child:Container(
padding:EdgeInsets.all(40),
color:Colors.lightGreen.shade200,
child:Text(
_gestureText,
style:TextStyle(fontSize:24),
),
),
),
),
);
}
}