如何处理GoRoute和ShellRoute的路由是最佳方法。
我有3个屏幕。 设置 - 全屏显示 A - 显示底部导航(使用Shelled Route包装) B - 显示底部导航(使用Shelled Route包装)
在这种配置中,我遇到的唯一问题是当我进入设置屏幕时缺少返回按钮。我该如何解决?
final goRouter = GoRouter(
initialLocation: '/a',
navigatorKey: _rootNavigatorKey,
routes: [
GoRoute( // = Do not show Bottom Navigation, just a full screen
path: '/settings',
pageBuilder: (context, state) => const NoTransitionPage(
child: SettingsPage(),
),
),
ShellRoute( // ShellRoute = Show Bottom Navigation
navigatorKey: _shellNavigatorKey,
builder: (context, state, child) {
return ScaffoldWithBottomNavigation(
tabs: tabs,
child: child,
);
},
routes: [
GoRoute(
path: '/a',
pageBuilder: (context, state) => const NoTransitionPage(
child: HomeScreen(label: 'A', detailsPath: '/a/details'),
),
routes: [
GoRoute(
path: 'details',
builder: (context, state) => const DetailsScreen(label: 'A'),
),
],
),
GoRoute(
path: '/b',
pageBuilder: (context, state) => const NoTransitionPage(
child: HomeScreen(label: 'B', detailsPath: '/b/details'),
),
routes: [
GoRoute(
path: 'details',
builder: (context, state) => const DetailsScreen(label: 'B'),
),
],
),
],
),
],
);