Navigating to the next screen
So far, all our examples have taken place on a single screen. In most real-world projects, you might be managing several screens, each with their own paths that can be pushed and popped onto the screen.
Flutter, and more specifically MaterialApp
, uses a class called Navigator
to manage your app's screens. Screens are abstracted into a concept called Routes
, which contain both the widget we want to show and how we want to animate them on the screen. Navigator
also keeps a full history of your routes so that you can return to the previous screens easily.
In this recipe, we're going to link LoginScreen
and StopWatch
so that LoginScreen
actually logs you in.
How to do it...
Let's start linking the two screens in the app:
- Start by engaging in one the most enjoyable activities for a developer – deleting code! Remove the
loggedIn
property and all the parts of the code where it's referenced. We're also no longer going to need the...