SchabanBo / qlevar_router

Manage you project Routes. Create nested routes. Simply navigation without context to your pages. Change only one sub widget in your page when navigating to new route.
MIT License
87 stars 22 forks source link

How to correctly restore navigation stack with temporary router? #150

Open BarashkovaElena opened 3 months ago

BarashkovaElena commented 3 months ago

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?

SchabanBo commented 1 month ago

Temporary router does not support state restoration yet