I am wondering, if anyone knows of a way to remove the back button that shows up on the appBar
in a flutter app when you use Navigator.pushNamed
to go to another page. The reason I do not want it on this resulting page is that it is coming from the navigation and I want users to use the logout
button instead, so that the session starts over.
I believe the solutions are the following
You actually either:
Don't want to display that ugly back button ( :] ), and thus go for :
AppBar(...,automaticallyImplyLeading: false,...)
;
Don't want the user to go back - replacing current view - and thus go for:
Navigator.pushReplacementNamed(## your routename here ##)
;
Don't want the user to go back - replacing a certain view back in the stack - and thus use:
Navigator.pushNamedAndRemoveUntil(## your routename here ##, f(Route<dynamic>)→bool);
where f is a function returning true
when meeting the last view you want to keep in the stack (right before the new one);
Don't want the user to go back - EVER - emptying completely the navigator stack with:
Navigator.pushNamedAndRemoveUntil(context, ## your routename here ##, (_) => false);
Cheers