Skip to content

Commit 0ef3f4b

Browse files
committed
fix(deps): pin go_router 18.1.1 for shell route pushes
With go_router 18.1.0, pushing a shell route over a root route that was itself pushed over the shell, such as push('/forbidden') and then push('/settings'), gave both shell pages the same page key and failed the Navigator assertion '!keyReservation.contains(key)' (flutter/flutter#140586). go_router 18.1.1 scopes the keys of the second shell page. A widget test drives that push through the app's router and fails on 18.1.0. 18.1.1 also stops wrapping unrelated async errors from redirects as GoException; the app's redirect is synchronous and never throws, so nothing else changes. The upgrade guide and README name the new version.
1 parent 62318bf commit 0ef3f4b

5 files changed

Lines changed: 27 additions & 5 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ The production environment is configured in `lib/infrastructure/config/environme
331331
| Flutter | 3.47.7 |
332332
| Dart | 3.13.5 |
333333
| State Management | flutter_bloc 9.1.1, bloc_concurrency 0.3.0, stream_transform 2.1.2 |
334-
| Routing | go_router 18.1.0 |
334+
| Routing | go_router 18.1.1 |
335335
| HTTP | dio 5.11.1 (interceptor chain: connectivity, auth, token-refresh, idempotency, resilience, cache, dev-console, logging, mock (dev/test only)) |
336336
| Forms | flutter_form_builder 10.3.0+2 |
337337
| Localization | intl 0.20.3, intl_utils 2.8.17 |

‎docs/upgrade_flutter_3.47.7.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Move every CI `flutter-version` pin in the same change.
6666

6767
| Package | Before | After | Notes |
6868
| --- | --- | --- | --- |
69-
| `go_router` | 17.3.0 | 18.1.0 | major; needs explicit pages, see 5.1 |
69+
| `go_router` | 17.3.0 | 18.1.1 | major; needs explicit pages, see 5.1 |
7070
| `sentry_flutter` | 9.22.0 | 10.1.0 | major; Android minSdk 26, Apple builds use SwiftPM only, see 5.3 |
7171
| `flutter_secure_storage` | 10.3.1 | 11.2.0 | major; no code change, see 5.4 |
7272
| `equatable` | 2.0.8 | 3.0.0 | major; no code change |
@@ -125,6 +125,8 @@ The fix keeps the 17.x behavior:
125125

126126
The only remaining difference is that go_router's internal `HeroController` uses a straight tween instead of the Material arc; the app has no `Hero` widgets.
127127
go_router 18.0.2 also wraps shell navigators in `Semantics(container: true)`, so the sidebar and top bar are now in the semantics tree on desktop.
128+
go_router 18.1.0 failed the Navigator assertion `'!keyReservation.contains(key)'` when a shell route was pushed over a root route that was itself pushed over the shell, for example `push('/forbidden')` and then `push('/settings')`, because both shell pages got the same page key (flutter/flutter#140586).
129+
18.1.1 gives the second shell page its own keys, and `app_router_pages_test.dart` covers that push.
128130

129131
### 5.2 dio 5.10 and later
130132

‎pubspec.lock‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ packages:
385385
dependency: "direct main"
386386
description:
387387
name: go_router
388-
sha256: "8b05bc90a4f8f8d579db351e2bd6bac566813e12953494dc2a9d7461e7c6dbe7"
388+
sha256: "07089be6dc124eb9596a51b5e359c657f30a59929287f11b126c2cd13eaaece0"
389389
url: "https://pub.dev"
390390
source: hosted
391-
version: "18.1.0"
391+
version: "18.1.1"
392392
hooks:
393393
dependency: transitive
394394
description:

‎pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818
flutter_localizations:
1919
sdk: flutter
2020
flutter_bloc: 9.1.1
21-
go_router: 18.1.0
21+
go_router: 18.1.1
2222
equatable: 3.0.0
2323
intl: 0.20.3
2424
flutter_form_builder: 10.3.0+2 # pinned: 11.x builds on material_ui and needs the app-wide material_ui migration

‎test/app/router/app_router_pages_test.dart‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:flutter_bloc_advance/app/router/app_routes_constants.dart';
77
import 'package:flutter_bloc_advance/app/router/forbidden_page.dart';
88
import 'package:flutter_bloc_advance/features/auth/presentation/pages/login_page.dart';
99
import 'package:flutter_bloc_advance/features/auth/presentation/pages/register_page.dart';
10+
import 'package:flutter_bloc_advance/features/settings/presentation/pages/settings_screen.dart';
1011
import 'package:flutter_test/flutter_test.dart';
1112
import 'package:go_router/go_router.dart';
1213
import 'package:logger/logger.dart' show Level, Logger, OutputEvent;
@@ -112,6 +113,25 @@ void main() {
112113
expect(rootPages(tester).last, isA<MaterialPage<void>>());
113114
});
114115

116+
// go_router 18.1.0 gave both shell pages the same page key and failed the Navigator assertion
117+
// '!keyReservation.contains(key)' (flutter/flutter#140586, fixed in 18.1.1).
118+
testWidgets('pushes a shell route over a root route pushed over the shell', (tester) async {
119+
setDesktopViewport(tester);
120+
TestEnv.authenticate();
121+
await tester.pumpWidget(const App(language: 'en'));
122+
await tester.pumpAndSettle();
123+
124+
routerFromApp(tester).push(ApplicationRoutesConstants.forbidden);
125+
await tester.pumpAndSettle();
126+
expect(find.byType(ForbiddenPage), findsOneWidget);
127+
128+
routerFromApp(tester).push(ApplicationRoutesConstants.settings);
129+
await tester.pumpAndSettle();
130+
131+
expect(find.byType(SettingsScreen), findsOneWidget);
132+
expect(routerFromApp(tester).state.uri.path, ApplicationRoutesConstants.settings);
133+
});
134+
115135
testWidgets('renders a Material not-found page for unknown locations', (tester) async {
116136
setDesktopViewport(tester);
117137
TestEnv.authenticate();

0 commit comments

Comments
 (0)