You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
petrovWF edited this page Jun 17, 2021
·
1 revision
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.
Requirements
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.
Router
This classes will wrap the RouterDelegate and provide it down the build tree.
AuthRouter
HomeRouter
RouterDelegate
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
Usage
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.