-
Notifications
You must be signed in to change notification settings - Fork 36
Navigator 2.0
Navigator 2.0
We use Navigator 2.0 which is the declarative way for navigation. We already implemented Navigator 2.0 and encourage you to continue using it but if you prefer the old imperative way feel free to make those changes.
For more detailed information about navigation and routing head to the official documentation.
Before you start using the declarative way for navigation you should be familiar with:
Page
Router
RouterDelegate
BackButtonDispatcher
Pages Pages are immutable objects and are used to set the navigators history stack. These are all implemented pages:
LoginPage
PasswordPage
UsernamePage
TaskDetailsPage
TaskListPage
LoadingPage
SettingsPage
Feel free to add or remove any of these.
This classes will wrap the RouterDelegate and provide it down the build tree.
- AuthRouter
- HomeRouter
This classes will inform the Router when to rebuild and they will decide which pages to be shown with the help of the state.
AppRouterDelegate
HomeRouterDelegate
AuthRouterDelegate
In app.dart
there are 3 global keys which can be used to access the wanted navigator even without context available.
Learn more about the navigatorKey.
In app.dart
build method, Router
instance will be created with:
routerDelegate: _appRouterDelegate
backButtonDispatcher: RootBackButtonDispatcher()
Root router for this application is AppRouterDelegate
.