DEV Community

Discussion on: Using Stacked Architecture in Flutter App

Collapse
 
blazebrain profile image
Blazebrain

Hi TG,

You can perform the check in the startup_viewmodel file and then route the user to the corresponding screen based on the result. If you save your tokens to local storage after successful login, you can check if the token exist in the startup_viewmodel file and route your user based on this. Another option is to set a boolean to true once logged in and false when logged out, then you route your user based on the value present in this boolean at the start of the application.

Thread Thread
 
hombregeek profile image
hombregeek • Edited

Thanks for this post, very interesting, I've got several ideas from it.

The solution when you tap an option to logout, returns to login page; we can use a flag to check is the token activated to allow this; but what about if the user tap on phone back button, it shows the early page. How can we avoid this behavior?

Thanks in advanced.

Update: I thought I found the solution replace _navigationService.navigateTo(Routes.homeView) for _navigationService.clearStackAndShowRoutes.homeView), I'm making test with this.