auto_route_library
auto_route_library copied to clipboard
How to avoid opening initial page when restoring state
I have an issue with restoring navigation state. In my test app there is a couple of pages. Sign-in page is initial.
@AutoRouterConfig(replaceInRouteName: 'Screen|Page,Route')
class AppRouter extends RootStackRouter {
@override
List<AutoRoute> get routes => [
AutoRoute(
page: SignUpRoute.page,
initial: true,
),
AutoRoute(
page: ExternalRoute.page,
),
}
Steps to reproduce the issue.
- Set "Don't keep activities" flag on Android device.
- Open the app.
- Call context.router.replace(const ExternalRoute());
- Note that the page of ExternalRoute opens (If you press back button at this point, it exits the app, because this page is now the only one in the stack.)
- Put the app to background.
- Restore the app. Expected result: ExternalRoute is restored. Back button closes the app, you cannot go back to SignInRoute. Actual result: ExternalRoute is restored, but back button leads to SignInRoute, which should not happen.