qlevar_router
qlevar_router copied to clipboard
How to correctly restore navigation stack with temporary router?
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:
- Enable "Don't keep activities" option on Android device.
- Open the app, from home page call showModalBottomSheet method.
- Put the app to background, so that the system kills its process.
- 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?