In my app i have three screens login , verifyotp , generatepass. I know how to move from one page to other page eg: Navigator.pushNamed(context, "/theNameOfThePage");
. I have a flow in which i move from login->verifyotp->generatepass my question is now how can i move from generatepass to login page and clearing all the stack. I am an android developer so in android we have intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
. How can i achieve same result in flutter!
Push a named route onto the navigator that most tightly encloses the given context. The route name will be passed to the Navigator. onGenerateRoute callback. The returned route will be pushed into the navigator. The new route and the previous route (if any) are notified (see Route.
Full clean of Navigator's history and navigate to new route:
void _logout() { Navigator.pushNamedAndRemoveUntil(context, "/newRouteName", (r) => false); }
Use Navigator.popUntil
.
void _logout() { Navigator.popUntil(context, ModalRoute.withName('/login')); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With