qlevar_router icon indicating copy to clipboard operation
qlevar_router copied to clipboard

How to correctly restore navigation stack with temporary router?

Open BarashkovaElena opened this issue 6 months ago • 1 comments

I have an issue with state restoration and temporarty router. Here are my routes:

class AppRoutes {
  static List<QRoute> bottomSheetRoutes = [
    QRoute(
        name: bottomSheetExamplePageName,
        path: bottomSheetExamplePagePath,
        builder: () => const BottomSheetExamplePage(),
    ),
  ];
  final routes = [
    QRoute(
        name: homePageName,
        path: homePagePath,
        pageType: const QPlatformPage(restorationId: homePageName),
        builder: () => const HomePage(),
        children: [
          ...bottomSheetRoutes,
        ],
  ];
}

I want to show bottom sheet over the home page with temporary router and call this method on HomePage:

    showModalBottomSheet(
      context: context,
      builder: (_) => TemporaryQRouter(
        path: '/temp_router',
        initPath: bottomSheetExamplePagePath,
        routes: AppRoutes.bottomSheetRoutes,
      ),
    );

The steps are the following:

  1. Enable "Don't keep activities" option on Android device.
  2. Open the app, from home page call showModalBottomSheet method.
  3. Put the app to background, so that the system kills its process.
  4. Return to the app, so that its state and route are restored. Expected result: the app is opened on the home page, the current path is '/home' Actual result: the app shows "Page not found', the current path is '/temp_router/bottom_sheet_example'

Is there a way to have the expected result?

BarashkovaElena avatar Aug 09 '24 13:08 BarashkovaElena