FilledStacks / flutter-tutorials

The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.
MIT License
4.75k stars 1.76k forks source link

Unable to use NavigationService with pushAndRemoveUntil #85

Closed akyjoe closed 4 years ago

akyjoe commented 4 years ago

Using MVVM architecture and stacked package, we are working on a basic User Login flow.

When user login successfully, pushNamed in the navigation service redirects user to home screen, but also allowing to navigate back to login screen. To fix that, we created another function in the navigation service with pushReplacementNamed and it worked, as it not allows user to move back.

But is there a way to use pushAndRemoveUntil without context? I tried navigating to your Youtube channel comment and found something below: image

But unable to replicate in the code. Are you saying to wrap the WillPopScope to the home screen?

FilledStacks commented 4 years ago

Hey, there's a a replaceWith function for the one you made. There's also a clearStackAndShow which will clear the stack and show the view you want to navigate to. There's also clearTillFirstAndShow which will clear till the first view and then navigate to your view. You can see it all here in the stacked services readme.