Repository navigation
Android Back Button Not Working On Any Tabs (Go_Router & ShellRoute) #139398
Copy link
Copy link
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.16Found to occur in 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18Found to occur in 3.18has 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.platform-androidAndroid applications specificallyAndroid applications specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
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
root
- /welcome
- /splash
- /home
- /explore
- /dialogs
- /notifications
- /settings
- /profile
App starts and decides which screen to start first with below
initialLocation: appManager.isFreshUser ? RoutePaths.welcome : RoutePaths.splash,
In both cases it navigates to home screen (With tabs explore, dialogs, notifications, settings) with below
router.go(RoutePaths.explore);
Expected results
The problem starts here, app do not close if physical back button and gives also zero reaction.
I want to close app(not kill) with back button when on home screen
Actual results
If we navigate to profile and then press back button, it goes back to home page. But the back button does not give reaction on home page.
Code sample
Code sample
final GlobalKey<NavigatorState> shellNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'shell');
final GlobalKey<NavigatorState> parentNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'parent');
final GoRouter router = GoRouter(
debugLogDiagnostics: true,
navigatorKey: parentNavigatorKey,
initialLocation: appManager.isFreshUser ? RoutePaths.welcome : RoutePaths.splash,
routes: [
GoRoute(
path: RoutePaths.welcome,
parentNavigatorKey: parentNavigatorKey,
builder: (context, state) => const WelcomeScreen(),
),
GoRoute(
path: RoutePaths.splash,
parentNavigatorKey: parentNavigatorKey,
builder: (context, state) => const SplashScreen(),
),
ShellRoute(
navigatorKey: shellNavigatorKey,
builder: (context, state, child) {
return HomeScreen();
},
routes: <RouteBase>[
GoRoute(
path: RoutePaths.explore,
parentNavigatorKey: shellNavigatorKey,
pageBuilder: (context, state) => const NoTransitionPage(
child: ExploreScreen(),
),
),
GoRoute(
path: RoutePaths.dialogs,
parentNavigatorKey: shellNavigatorKey,
pageBuilder: (context, state) => NoTransitionPage(
key: state.pageKey,
child: const DialogsScreen(),
),
),
GoRoute(
path: RoutePaths.notifications,
parentNavigatorKey: shellNavigatorKey,
pageBuilder: (context, state) => NoTransitionPage(
key: state.pageKey,
child: const NotificationsScreen(),
),
),
GoRoute(
path: RoutePaths.settings,
parentNavigatorKey: shellNavigatorKey,
pageBuilder: (context, state) => NoTransitionPage(
key: state.pageKey,
child: const SettingsScreen(),
),
),
],
),
GoRoute(
path: RoutePaths.profile,
parentNavigatorKey: parentNavigatorKey,
builder: (context, state) => const ProfileScreen(),
),Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.16.1, on macOS 13.5.2 22G91 darwin-arm64, locale en-TR)
• Flutter version 3.16.1 on channel stable at /Users/mee/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7f20e5d18c (4 days ago), 2023-11-27 09:47:30 -0800
• Engine revision 22b600f240
• Dart version 3.2.1
• DevTools version 2.28.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/mee/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/mee/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• 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 17.0.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.80.0)
• VS Code at /Users/mee/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.78.0
[✓] Connected device (5 available)
• MI 6 (mobile) • 66eafcf3 • android-arm64 • Android 9 (API 28)
• Mee’s IPhone (mobile) • 00008101-0006014A2278001E • ios • iOS 17.1.1 21B91
• iPhone 11 Pro Max (mobile) • E6D4F26D-A7CA-4FB6-86FE-B9DBAB77F575 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.5.2 22G91 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.199
[✓] Network resources
• All expected network resources are available.
• No issues found!Reactions are currently unavailable
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.16Found to occur in 3.16Found to occur in 3.16found in release: 3.18Found to occur in 3.18Found to occur in 3.18has 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.platform-androidAndroid applications specificallyAndroid applications specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Activity
darshankawar commentedon Dec 4, 2023
@jostney
Can you take a look at this issue and see if it resembles your case or not ?
jostney commentedon Dec 4, 2023
I have looked the issue, but mine issue is not for whole app itself, just for screens with shell router
Above is general path of the app, basically it starts with
welcome-->splash-->homeThe home screen hosts for
explore,dialogs,notifications,settingsscreensUser can navigate from
dialogstoconversationscreen like in WhatsApp, in this case it can able to navigate back via physical back button. But the back button does not function onexplore,dialogs,notifications,settingstabs. It must close the app (okay not kill)I'm sure i never integrate something
WillPopScopeor etc on in the app, which can block the back behaviour.Hopefully i implemented a workaround for this and its working (But the problem still existing actually)
darshankawar commentedon Dec 5, 2023
Thanks for the update. Seeing the same behavior as reported.
stable, master flutter doctor -v
14 remaining items
flutter-triage-bot commentedon Oct 11, 2025
This issue is marked P1 but has had no recent status updates.
The P1 label indicates high-priority issues that are at the top of the work list. This is the highest priority level a bug can have if it isn't affecting a top-tier customer or breaking the build. Bugs marked P1 are generally actively being worked on unless the assignee is dealing with a P0 bug (or another P1 bug). Issues at this level should be resolved in a matter of months and should have monthly updates on GitHub.
Please consider where this bug really falls in our current priorities, and label it or assign it accordingly. This allows people to have a clearer picture of what work is actually planned. Thanks!