Navigate out from CupertinoTabScaffold
Found solution from the official FlutterGallery source code. This will navigate route to root.
Navigator.of(context, rootNavigator: true).pop();
Jofre
Flutter and Java Android developer with 9 years of experience. A part from Mobile development I also have basic knowledge of Backend development with Node.js.
Updated on December 02, 2022Comments
-
Jofre over 1 year
I have an App with a LoginScreen that goes to the HomeScreen after a success login. I use this code below to replace the widget and start a new navigation Stack:
Navigator.pushReplacement( context, CupertinoPageRoute( builder: (context) => HomeScreen(), ), );
The HomeScreen is a
CupertinoTabScaffold
with 2CupertinoTabViews
.The second
CupertinoTabView
contain a Widget that has a logout button.After a success logout I want to remove the HomeWidget, and go to LoginScreen.
Using
Navigator.pushReplacement( context, CupertinoPageRoute( builder: (context) => LoginScreen(), ), );
in a Widget inside the second
CupertinoTabView
only reset its navigation, and the LoginScreen appears inside the secondCupertinoTabView
.What I want is some code to remove my HomeScreen and start a new Navigation stack with the LoginScreen.
-
Jofre almost 5 yearsI used the solution accepted in this post, as a workaround, but I'm not happy with it. stackoverflow.com/questions/50115311/…
-