edge-swipe back disable (on scaffold)

1,838 views
Skip to first unread message

david...@gmail.com

unread,
Nov 5, 2017, 12:05:24 PM11/5/17
to Flutter Dev
Hello, i have a basic flutter app with two classes that extends statefullwidget class, the first is a login form and the second a basic page with a basic drawer. I would like to prevent my app to navigate back to the login page if the user activate the edge-swipe gesture. 
thanks in advance

Xiao Yu

unread,
Nov 5, 2017, 3:35:23 PM11/5/17
to Flutter Dev
If you use Material or CupertinoPageRoute, you can prevent a back swipe if you pushed your route as a fullscreenDialog (https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/cupertino/route.dart#L85). Using a WillPopScope (https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/will_pop_scope.dart) also lets you control when a navigation pop is allowed. It also disables a back swipe. 

Though in your specific case, it sounds like you don't need to keep your login page around. You can use pushReplacement on the Navigator (https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/navigator.dart#L681) to replace the first page altogether. 

david...@gmail.com

unread,
Nov 7, 2017, 3:32:03 AM11/7/17
to Flutter Dev
thanks, that's what i need :d..i have one more question: how can i catch the routing event? i mean when the transition ends
thanks in advance
Reply all
Reply to author
Forward
0 new messages