-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/packages
#5497Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Define top level routes and shell routes
- Navigate to a shell route from a top level route using context.pushNamed()
- The bottom navigation bar isn't visible
Expected results
The shell route should load the bottom navigation bar
Actual results
The bottom navigation bar isn't visible
Code sample
Code sample
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(
MyApp(),
);
}
class MyRouter {
static final GlobalKey<NavigatorState> _rootNavigator =
GlobalKey<NavigatorState>(debugLabel: 'root');
static String agentRouteName = '/agent';
static String homeRouteName = '/home';
static String profileRouteName = '/profile';
static GoRouter router = GoRouter(
navigatorKey: _rootNavigator,
debugLogDiagnostics: kDebugMode,
initialLocation: '/agent',
routes: [
GoRoute(
name: agentRouteName,
path: '/agent',
builder: (context, state) {
return AgentPage();
},
),
StatefulShellRoute.indexedStack(
builder: (context, state, navigationShell) {
return NavPage(navigationShell: navigationShell);
},
branches: [
StatefulShellBranch(
routes: [
GoRoute(
name: homeRouteName,
path: '/home',
pageBuilder: (context, state) {
return NoTransitionPage(child: HomePage());
},
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
name: profileRouteName,
path: '/profile',
pageBuilder: (context, state) {
return NoTransitionPage(child: ProfilePage());
},
),
],
),
],
),
]);
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Reproducible code',
debugShowCheckedModeBanner: false,
routerConfig: MyRouter.router,
);
}
}
class AgentPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Agent page')),
body: Center(
child: ElevatedButton(
onPressed: () => context.pushNamed(MyRouter.homeRouteName),
child: Text('Go to home page'),
),
),
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Home page')),
body: Text('Home Page'),
);
}
}
class ProfilePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Profile page')),
body: Text('Profile Page'),
);
}
}
class NavPage extends StatelessWidget {
final StatefulNavigationShell navigationShell;
const NavPage({
required this.navigationShell,
super.key,
});
@override
Widget build(BuildContext context) {
return Scaffold(
body: navigationShell,
bottomNavigationBar: NavigationBar(
selectedIndex: navigationShell.currentIndex,
destinations: const [
NavigationDestination(label: 'Home Page', icon: Icon(Icons.home)),
NavigationDestination(
label: 'Profile Page', icon: Icon(Icons.person)),
],
onDestinationSelected: _goBranch,
),
);
}
void _goBranch(int index) {
navigationShell.goBranch(index);
}
}
Screenshots or Video
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4.1 22F82 darwin-arm64, locale en-ET)
• Flutter version 3.10.5 on channel stable at /Users/abdi/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (4 weeks ago), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/abdi/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /Users/abdi/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14B47b
• CocoaPods version 1.12.0
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.80.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.68.0
[✓] Connected device (2 available)
• sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11 (API
30) (emulator)
• iPhone 14 (mobile) • 5CE9B48C-9ED1-4629-B822-FF785744D0C9 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
[✓] Network resources
• All expected network resources are available.
• No issues found!yeaminChy
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version

