I am using ShellRoute to control BottomNavigationBar. It works fine. But when I try context.go
I get the message that the given path was not found.
static final _rootNavigatorKey = GlobalKey<NavigatorState>();
static final _shellNavigatorKey = GlobalKey<NavigatorState>();
static final GoRouter router = GoRouter(
initialLocation: AppRoutes.home,
debugLogDiagnostics: true,
navigatorKey: _rootNavigatorKey,
routes: [
ShellRoute(
navigatorKey: _shellNavigatorKey,
builder: (context, state, child) {
return BlocProvider(
create: (context) => NavigationCubit(),
child: MainScreen(child: child),
);
},
routes: [
GoRoute(
parentNavigatorKey: _shellNavigatorKey,
path: AppRoutes.home,
pageBuilder: (context, state) => const NoTransitionPage(
child: HomeScreen(),
),
routes: [
GoRoute(
parentNavigatorKey: _shellNavigatorKey,
path: AppRoutes.homeDetails,
builder: (context, state) => const HomeDetailsScreen(),
),
],
),
GoRoute(
parentNavigatorKey: _shellNavigatorKey,
path: AppRoutes.profile,
pageBuilder: (context, state) => const NoTransitionPage(
child: ProfileScreen(),
),
routes: [
GoRoute(
parentNavigatorKey: _shellNavigatorKey,
path: AppRoutes.profileDetails,
builder: (context, state) => const ProfileDetailsScreen(),
),
],
),
GoRoute(
parentNavigatorKey: _shellNavigatorKey,
path: AppRoutes.settings,
pageBuilder: (context, state) => const NoTransitionPage(
child: SettingsScreen(),
),
),
],
),
],
errorBuilder: (context, state) => const ErrorScreen(),
);
When i try go to AppRoutes.homeDatails
form AppRoutes.home
:
context.go(AppRoutes.homeDetails),
I got the result:
[GoRouter] No initial matches: details
I tried adding parentNavigatorKey
but it didn't help.
GoRouter.of(context).go(AppRoutes.homeDetails)
not working too.