auto_route_library icon indicating copy to clipboard operation
auto_route_library copied to clipboard

How to avoid opening initial page when restoring state

Open BarashkovaElena opened this issue 6 months ago • 0 comments

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.

  1. Set "Don't keep activities" flag on Android device.
  2. Open the app.
  3. Call context.router.replace(const ExternalRoute());
  4. 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.)
  5. Put the app to background.
  6. 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.

BarashkovaElena avatar Aug 19 '24 12:08 BarashkovaElena