Repository navigation
Closed
flutter/packages
#12549Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.found 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.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Steps to reproduce
-
Copy the paste the given code, &
pubspec.ymal -
dart run build_runner watch --delete-conflicting-outputs
-
Keep Clicking on the button
From screen A -> Push to B -> Push to C -> Push Replacement to A -> (Push to B) cause the error.
Note, B & C is in shell route...
Expected results
It should have push to the intented route,
Actual results
I see an error in the console (see the "Logs" section).
This only started happening since go_router: ^13.0.0 which was released 2 days ago.
Also, found similar reporting earlier,
#107045
Code sample
Code sample
Pubspec.yaml
name: go_router_bug
description: "A new Flutter project."
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: '>=3.2.3 <4.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
go_router: ^13.0.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
build_runner: ^2.4.7
go_router_builder: ^2.4.0
flutter:
uses-material-design: truemain.dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
part 'main.g.dart';
void main() {
runApp(const MyApp());
}
final parentNavigationKey = GlobalKey<NavigatorState>();
final shellRouteKey = GlobalKey<NavigatorState>();
class AScreen extends StatelessWidget {
const AScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('A Screen')),
body: Center(
child: FilledButton(
onPressed: () => const BScreenRoute().push<void>(context),
child: const Text('Push to B'),
),
),
);
}
}
class BScreen extends StatelessWidget {
const BScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('B Screen')),
body: Center(
child: FilledButton(
onPressed: () => const CScreenRoute().push(context),
child: const Text('Push to C'),
),
),
);
}
}
class CScreen extends StatelessWidget {
const CScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('C Screen')),
body: Center(
child: FilledButton(
onPressed: () => const AScreenRoute().pushReplacement(context),
child: const Text('Push Replacement to A'),
),
),
);
}
}
@TypedGoRoute<AScreenRoute>(
path: '/a',
name: 'a',
)
@immutable
class AScreenRoute extends GoRouteData {
const AScreenRoute();
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return NoTransitionPage(
key: state.pageKey,
child: const AScreen(),
);
}
}
@immutable
class BScreenRoute extends GoRouteData {
const BScreenRoute();
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return NoTransitionPage(
key: state.pageKey,
child: const BScreen(),
);
}
}
@immutable
class CScreenRoute extends GoRouteData {
const CScreenRoute();
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return NoTransitionPage(
key: state.pageKey,
child: const CScreen(),
);
}
}
@TypedShellRoute<BAndCScreenShellRoute>(routes: [
TypedGoRoute<BScreenRoute>(
path: '/b',
name: 'b',
),
TypedGoRoute<CScreenRoute>(
path: '/c',
name: 'c',
),
])
@immutable
class BAndCScreenShellRoute extends ShellRouteData {
const BAndCScreenShellRoute();
static final GlobalKey<NavigatorState> $navigatorKey = shellRouteKey;
@override
Page<void> pageBuilder(
BuildContext context,
GoRouterState state,
Widget navigator,
) {
return NoTransitionPage(
key: state.pageKey,
child: navigator,
);
}
}
final router = GoRouter(
navigatorKey: parentNavigationKey,
initialLocation: '/a',
routes: [
$aScreenRoute,
$bAndCScreenShellRoute,
],
);
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routeInformationProvider: router.routeInformationProvider,
routeInformationParser: router.routeInformationParser,
routerDelegate: router.routerDelegate,
theme: ThemeData(
colorScheme: const ColorScheme.highContrastLight(secondary: Colors.amber),
),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
estarted application in 3,265ms.
════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building HeroControllerScope:
'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3817 pos 18: '!keyReservation.contains(key)': is not true.
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.yml
The relevant error-causing widget was:
MaterialApp MaterialApp:file:///C:/flutter-bug-report/go_router_bug/lib/main.dart:148:24
When the exception was thrown, this was the stack:
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.yml
The relevant error-causing widget was:
MaterialApp MaterialApp:file:///C:/flutter-bug-report/go_router_bug/lib/main.dart:148:24
When the exception was thrown, this was the stack:
#2 NavigatorState._debugCheckDuplicatedPageKeys.<anonymous closure> (package:flutter/src/widgets/navigator.dart:3817:18)
navigator.dart:3817
#3 NavigatorState._debugCheckDuplicatedPageKeys (package:flutter/src/widgets/navigator.dart:3822:6)
navigator.dart:3822
#4 NavigatorState._updatePages.<anonymous closure> (package:flutter/src/widgets/navigator.dart:3884:7)
navigator.dart:3884
#5 NavigatorState._updatePages (package:flutter/src/widgets/navigator.dart:3887:6)
navigator.dart:3887
#6 NavigatorState.didUpdateWidget (package:flutter/src/widgets/navigator.dart:3803:7)
navigator.dart:3803
#7 StatefulElement.update (package:flutter/src/widgets/framework.dart:5643:55)
framework.dart:5643
#8 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
framework.dart:3815
#9 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
framework.dart:5496
#10 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
framework.dart:5187
#11 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
framework.dart:5800
#12 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
framework.dart:3815
#13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
framework.dart:5496
#14 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
framework.dart:5187
#15 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
framework.dart:5800
#16 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:105:11)
inherited_notifier.dart:105
#17 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
framework.dart:3815
#18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
framework.dart:5496
#19 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
framework.dart:5634
#20 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
framework.dart:5187
#21 StatefulElement.update (package:flutter/src/widgets/framework.dart:5657:5)
framework.dart:5657
#22 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
framework.dart:3815
#23 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
framework.dart:5496
#24 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
framework.dart:5187
#25 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
framework.dart:5800
#26 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
framework.dart:3815
#27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
#28 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
framework.dart:5187
#29 StatelessElement.update (package:flutter/src/widgets/framework.dart:5547:5)
framework.dart:5547
#30 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
framework.dart:3815
#31 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
framework.dart:5496
#32 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
framework.dart:5187
#33 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
framework.dart:5800
#34 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
framework.dart:3815
#35 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
framework.dart:5496
#36 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
framework.dart:5187
#37 ProxyElement.update (package:flutter/src/widgets/framework.dart:5800:5)
framework.dart:5800
#38 Element.updateChild (package:flutter/src/widgets/framework.dart:3815:15)
framework.dart:3815
#39 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5496:16)
framework.dart:5496
#40 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5634:11)
framework.dart:5634
#41 Element.rebuild (package:flutter/src/widgets/framework.dart:5187:7)
framework.dart:5187
#42 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2895:19)
framework.dart:2895
#43 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:984:21)
binding.dart:984
#44 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:457:5)
binding.dart:457
#45 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1325:15)
binding.dart:1325
#46 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1255:9)
binding.dart:1255
#47 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:5)
binding.dart:1113
#48 _invoke (dart:ui/hooks.dart:312:13)
hooks.dart:312
#49 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:383:5)
platform_dispatcher.dart:383
#50 _drawFrame (dart:ui/hooks.dart:283:31)
hooks.dart:283
(elided 2 frames from class _AssertionError)Flutter Doctor output
Doctor output
PS C:\flutter-bug-report\go_router_bug> flutter doctor -v
[!] Flutter (Channel stable, 3.16.4, on Microsoft Windows [Version 10.0.22621.2861], locale en-IN)
• Flutter version 3.16.4 on channel stable at C:\Users\harsh\fvm\default
! Warning: `flutter` on your path resolves to C:\Users\harsh\fvm\versions\stable\bin\flutter, which is not inside
your current Flutter SDK checkout at C:\Users\harsh\fvm\default. Consider adding C:\Users\harsh\fvm\default\bin to the front of your path.
! Warning: `dart` on your path resolves to C:\Users\harsh\fvm\versions\stable\bin\dart, which is not inside your
current Flutter SDK checkout at C:\Users\harsh\fvm\default. Consider adding C:\Users\harsh\fvm\default\bin to the
front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2e9cb0aa71 (13 days ago), 2023-12-11 14:35:13 -0700
• Engine revision 54a7145303
• Dart version 3.2.3
• DevTools version 2.28.4
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
to perform update checks and upgrades.
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at C:\Users\harsh\AppData\Local\Android\sdk
• Platform android-34, build-tools 33.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at C:\Users\harsh\AppData\Local\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.4)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33213.308
• Windows 10 SDK version 10.0.22000.0
[✓] Android Studio (version 2022.1)
• 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 11.0.15+0-b2043.56-8887301)
[✓] IntelliJ IDEA Community Edition (version 2023.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.2.1
• 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
[✓] VS Code (version 1.85.1)
• VS Code at C:\Users\harsh\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.56.0
[✓] Connected device (4 available)
• vivo 1907 (mobile) • 8TBYBE6H7H55USFE • android-arm64 • Android 12 (API 31)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.2861]
• Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.129
• Edge (web) • edge • web-javascript • Microsoft Edge 118.0.2088.76
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.Reacted by Muhammet Arslan, Joaquín Pérez, grove86darshak, Harshit Kumar , Jimmy Aumard, Abel Wang, Damian Bast, Sergio Molchanovsky, CedricBaijot, Zlati Pehlivanov and 57 more
Reacted by youssef ali and ajamespro
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.found 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.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Activity
[-][go_router] A page pushed twice will fail the assertion !keyReservation.contains(key)[/-][+][go_router] 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3817 pos 18: '!keyReservation.contains(key)': is not true.[/+][-][go_router] 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3817 pos 18: '!keyReservation.contains(key)': is not true.[/-][+][go_router] Failed assertion: line 3817 pos 18: '!keyReservation.contains(key)': is not true.[/+]danagbemava-nc commentedon Dec 27, 2023
Hi @Vedsaga, thanks for filing this issue. Which version of go_router were you using prior to upgrading to
13.0.0?Vedsaga commentedon Dec 28, 2023
Was on 12.1.3 which was latest version before major version update to 13.0.0
cc:
@danagbemava-nc
danagbemava-nc commentedon Dec 28, 2023
Thanks for the update.
I can confirm this is a regression in go_router 13.0.0 as the bug did not reproduce on 12.1.3 but it did on 13.0.0
flutter doctor -v
67 remaining items
cubelated commentedon Jan 16, 2026
Issue still exists with GoRouter v17.0.0
mu7mmd commentedon Jan 25, 2026
Issue still exists with versions: 13, 14, 15, 16, and 17.
[go_router] Fix duplicate page key when re-entering a shell route
Agyapaldhiman commentedon Jul 24, 2026
Is anyone currently working on this issue? It’s becoming quite frustrating and is causing ongoing problems.
[go_router] Fix duplicate page key when re-entering a shell route
[go_router] Fix shell route key collisions and dynamic branch updates (…
fix(deps): pin go_router 18.1.1 for shell route pushes
github-actions commentedon Oct 28, 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.