File tree 4 files changed +49
-5
lines changed 4 files changed +49
-5
lines changed Original file line number Diff line number Diff line change
1
+ ## 12.0.2
2
+
3
+ - Fixes the problem that pathParameters is null in redirect when the Router is recreated.
4
+
1
5
## 12.0.1
2
6
3
7
- Fixes deep-link with no path on cold start.
Original file line number Diff line number Diff line change @@ -495,17 +495,19 @@ class RouteConfiguration {
495
495
final RouteBase route = match.route;
496
496
FutureOr <String ?> routeRedirectResult;
497
497
if (route is GoRoute && route.redirect != null ) {
498
+ final RouteMatchList effectiveMatchList =
499
+ match is ImperativeRouteMatch ? match.matches : matchList;
498
500
routeRedirectResult = route.redirect !(
499
501
context,
500
502
GoRouterState (
501
503
this ,
502
- uri: matchList .uri,
504
+ uri: effectiveMatchList .uri,
503
505
matchedLocation: match.matchedLocation,
504
506
name: route.name,
505
507
path: route.path,
506
- fullPath: matchList .fullPath,
507
- extra: matchList .extra,
508
- pathParameters: matchList .pathParameters,
508
+ fullPath: effectiveMatchList .fullPath,
509
+ extra: effectiveMatchList .extra,
510
+ pathParameters: effectiveMatchList .pathParameters,
509
511
pageKey: match.pageKey,
510
512
),
511
513
);
Original file line number Diff line number Diff line change 1
1
name : go_router
2
2
description : A declarative router for Flutter based on Navigation 2 supporting
3
3
deep linking, data-driven routes and more
4
- version : 12.0.1
4
+ version : 12.0.2
5
5
repository : https://github.com/flutter/packages/tree/main/packages/go_router
6
6
issue_tracker : https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22
7
7
Original file line number Diff line number Diff line change @@ -5048,6 +5048,44 @@ void main() {
5048
5048
expectedInitialRoute);
5049
5049
});
5050
5050
});
5051
+
5052
+ testWidgets (
5053
+ 'test the pathParameters in redirect when the Router is recreated' ,
5054
+ (WidgetTester tester) async {
5055
+ final GoRouter router = GoRouter (
5056
+ initialLocation: '/foo' ,
5057
+ routes: < RouteBase > [
5058
+ GoRoute (
5059
+ path: '/foo' ,
5060
+ builder: dummy,
5061
+ routes: < GoRoute > [
5062
+ GoRoute (
5063
+ path: ':id' ,
5064
+ redirect: (_, GoRouterState state) {
5065
+ expect (state.pathParameters['id' ], isNotNull);
5066
+ return null ;
5067
+ },
5068
+ builder: dummy,
5069
+ ),
5070
+ ],
5071
+ ),
5072
+ ],
5073
+ );
5074
+ await tester.pumpWidget (
5075
+ MaterialApp .router (
5076
+ key: UniqueKey (),
5077
+ routerConfig: router,
5078
+ ),
5079
+ );
5080
+ router.push ('/foo/123' );
5081
+ await tester.pump (); // wait reportRouteInformation
5082
+ await tester.pumpWidget (
5083
+ MaterialApp .router (
5084
+ key: UniqueKey (),
5085
+ routerConfig: router,
5086
+ ),
5087
+ );
5088
+ });
5051
5089
}
5052
5090
5053
5091
class TestInheritedNotifier extends InheritedNotifier <ValueNotifier <String >> {
You can’t perform that action at this time.
0 commit comments