Repository navigation
Closed
flutter/packages
#12611Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32Found to occur in 3.32has 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.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Steps to reproduce
Reproducible in go_router 15.0.0
Start with the following config:
final config = RoutingConfig(routes: [
StatefulShellRoute.indexedStack(
restorationScopeId: 'navigationShell',
builder: builder,
branches: [
StatefulShellBranch(
restorationScopeId: 'home',
routes: [
GoRoute(path: '/home', builder: homeBuilder, routes: [
GoRoute(path: '/a', builder: ABuilder)
])
]
),
],
),
]);and add a button on ABuilder to update the routing config:
configNotifier.value = RoutingConfig // Same value as above- From the home branch, navigate to
/home/ausing the push method ( imperative ). The issue doesn't happen with the go method. - Click the reload button on the A widget
- Observe that the reload redirected the user back to
/home
Expected results
Update route config, stay in the route: /home/a, and the history of the branch should be maintained
Actual results
Route config is updated but the history of the branch is lost, and the app redirected to /home
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const App());
}
class App extends StatelessWidget {
static final routingConfig = ValueNotifier<RoutingConfig>(createConfig());
static final routerConfig = GoRouter.routingConfig(
restorationScopeId: 'app-router',
initialLocation: '/home',
routingConfig: routingConfig,
);
const App({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
restorationScopeId: 'app',
routerConfig: routerConfig,
);
}
}
Widget builder(
BuildContext context,
GoRouterState state,
StatefulNavigationShell shell,
) {
return Scaffold(
bottomNavigationBar: NavigationBar(
selectedIndex: shell.currentIndex,
onDestinationSelected: (index) => shell.goBranch(index),
destinations: [
NavigationDestination(icon: const Icon(Icons.abc), label: 'Main'),
NavigationDestination(icon: const Icon(Icons.abc), label: 'Ignore'),
],
),
body: Center(child: shell),
);
}
RoutingConfig createConfig() {
return RoutingConfig(
routes: [
StatefulShellRoute.indexedStack(
restorationScopeId: 'navigationShell',
builder: builder,
branches: [
StatefulShellBranch(
restorationScopeId: 'main',
routes: [
GoRoute(
path: '/home',
builder: createBuilder('main', canNavigate: true),
routes: [
GoRoute(
path: '/a',
builder: createBuilder('a', allowReload: true),
),
],
),
],
),
StatefulShellBranch(
restorationScopeId: 'ignore',
routes: [
GoRoute(
path: '/ignore',
builder: createBuilder('ignore', canNavigate: true),
),
],
),
],
),
],
);
}
Widget Function(BuildContext, GoRouterState) createBuilder(
String name, {
bool allowReload = false,
bool canNavigate = false,
}) {
return (ctx, state) =>
MyPage(allowReload: allowReload, canNavigate: canNavigate, name: name);
}
class MyPage extends StatelessWidget {
final bool allowReload;
final bool canNavigate;
final String name;
const MyPage({
super.key,
required this.allowReload,
required this.canNavigate,
required this.name,
});
@override
Widget build(BuildContext context) {
return Material(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (allowReload)
ElevatedButton(
onPressed: () {
App.routingConfig.value = createConfig();
},
child: Text("Press me to reload config"),
),
if (canNavigate)
ElevatedButton(
onPressed: () {
GoRouter.of(context).push('/home/a');
},
child: Text("Press me to navigate to nested route"),
),
Text(name),
],
),
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.29.1, on Microsoft Windows [Version 10.0.26100.3775], locale el-GR) [381ms]
• Flutter version 3.29.1 on channel stable at C:\Users\itsUndefined\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 09de023485 (7 weeks ago), 2025-02-28 13:44:05 -0800
• Engine revision 871f65ac1b
• Dart version 3.7.0
• DevTools version 2.42.2
[√] Windows Version (11 Pro 64-bit, 24H2, 2009) [1.989ms]
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [2,9s]
• Android SDK at C:\Users\itsUndefined\AppData\Local\Android\Sdk
• Platform android-35, build-tools 35.0.1
• ANDROID_HOME = C:\Users\itsUndefined\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
• All Android licenses accepted.
[√] Chrome - develop for the web [120ms]
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.13.6) [118ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.13.35931.197
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2024.2) [16ms]
• Android Studio at C:\Program Files\Android\Android Studio
• 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 21.0.5+-13047016-b750.29)
[√] VS Code (version 1.99.2) [14ms]
• VS Code at C:\Users\itsUndefined\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.108.0
[√] Connected device (4 available) [268ms]
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 15 (API 35) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26100.3775]
• Chrome (web) • chrome • web-javascript • Google Chrome 135.0.7049.85
• Edge (web) • edge • web-javascript • Microsoft Edge 135.0.3179.73
[√] Network resources [341ms]
• All expected network resources are available.
• No issues found!Reacted by Insider32
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.29Found to occur in 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32Found to occur in 3.32has 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.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Activity
maheshj01 commentedon Apr 18, 2025
Hey @itsUndefined,
and the page stays on /home/a
Screen.Recording.2025-04-17.at.22.17.39.mov
code sample
flutter doctor -v
stable
itsUndefined commentedon Apr 18, 2025
Hi. This happens on Android platform. Sorry I forgot to mention.
maheshj01 commentedon Apr 18, 2025
Hey @itsUndefined I am unable to reproduce it on my end used the code sample here #167344 (comment)
Screen.Recording.2025-04-18.at.15.05.06.mov
Is this happening on a specific browser or device?
itsUndefined commentedon Apr 18, 2025
I am not creating a website. I am creating an android app. This issue doesn't happen in a browser but in an app.
maheshj01 commentedon Apr 18, 2025
I see sorry about that and Thanks for the clarification.
Reproducible on stable and the master channel updating the GoRouter.routeConfig loses the router state
Screen.Recording.2025-04-18.at.16.21.38.mov
flutter doctor -v
master
stable
7 remaining items
georgiosd commentedon May 29, 2025
@maheshj01 don’t mean to be annoying but this is blocking for us. Any idea roughly the ETA?
itsUndefined commentedon Jun 2, 2025
@chunhtai I managed to identify the root cause of the issue. It's in the method
RouteConfiguration.reparse. This method only handles ImperativeRouteMatches in the root navigator. It doesn't handle ImperativeRouteMatches inside ShellRouteMatches. I confirmed that in my example, the code below fixes the issue but it's not production ready. I think ShellRoutes can be nested infinitely deep so we need a recursive solution?Here is what I changed locally to fix the issue:
I am tagging you since I saw that you are the original author of this method.
[go_router] Preserve nested pushes during config updates (#12611)
[go_router] Preserve nested pushes during config updates (flutter#12611)
github-actions commentedon Oct 6, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.