Detect swipes in Flutter!

GestureDetector(
onTap: () {
print('Widget Tapped');
},
child: Container(),
),
onHorizontalDragUpdate: (details) {
if (details.delta.direction > 0) {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Page2()));
}
},
onVerticalDragUpdate: (details) {},
onHorizontalDragUpdate: (details) {
if (details.delta.direction > 0) {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Page2()));
}
},
onVerticalDragUpdate: (details) {},
onHorizontalDragUpdate: (details) {
if (details.delta.direction <= 0) {
Navigator.pop(context);
}
},

Don’t forget to connect with me on:

Don’t stop, until you are breathing!💙
- Abhishek Doshi

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Doshi

Abhishek Doshi

1.92K Followers

Google Developer Expert — Dart, Flutter & Firebase 💙💛