From the course: Flutter Essential Training: Build for Multiple Platforms

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Replacing routes using Navigator

Replacing routes using Navigator

- [Instructor] Do you know what is wrong with our navigation logic? Let me show you, Here I'm writing my name and then I'm logging in. Now, if I navigate to chat page from login I will be able to go back to the login page from this back button created right here. Or maybe I can just slide back in if I'm on iOS device and if you're using Android you can do the same via the hardware back button. Now, in most cases, this probably makes sense. However, right now we are navigating from login page to chat page, and once the login has been successful this route should be removed from the stack completely and be replaced with chat page. So instead of pushing a route on top of login we should just replace this chat route with the login route. So it's not possible for the user to go back casually like that after a successful login. So now navigator has a push and replacement method that pushes a route replacing the current route.…

Contents