Skip to content

Commit 32cb9dd

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature-debug-full-path
2 parents c855781 + 6507c42 commit 32cb9dd

File tree

6 files changed

+58
-5
lines changed

6 files changed

+58
-5
lines changed

.ci/flutter_master.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0d22d9101aacb49f62517b9af954f99fd5162357
1+
00425ef1be267826da3a9ada01efd74727a66420

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
cd $GITHUB_WORKSPACE
3737
# Checks out a copy of the repo.
3838
- name: Check out code
39-
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
39+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
4040
with:
4141
fetch-depth: 0 # Fetch all history so the tool can get all the tags to determine version.
4242
- name: Set up tools

.github/workflows/scorecards-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: "Checkout code"
24-
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v2.4.0
24+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v2.4.0
2525
with:
2626
persist-credentials: false
2727

packages/go_router/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
## 14.1.2
1+
## 14.1.3
22

33
- Improves the logging of routes when `debugLogDiagnostics` is enabled or `debugKnownRoutes() is called. Explains the position of shell routes in the route tree. Prints the widget name of the routes it is building.
44

5+
## 14.1.2
6+
7+
- Fixes issue that path parameters are not set when using the `goBranch`.
8+
59
## 14.1.1
610

711
- Fixes correctness of the state provided in the `onExit`.

packages/go_router/lib/src/route.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,12 @@ class StatefulNavigationShell extends StatefulWidget {
11341134
/// Recursively traverses the routes of the provided StackedShellBranch to
11351135
/// find the first GoRoute, from which a full path will be derived.
11361136
final GoRoute route = branch.defaultRoute!;
1137-
return _router.configuration.locationForRoute(route)!;
1137+
final List<String> parameters = <String>[];
1138+
patternToRegExp(route.path, parameters);
1139+
assert(parameters.isEmpty);
1140+
final String fullPath = _router.configuration.locationForRoute(route)!;
1141+
return patternToPath(
1142+
fullPath, shellRouteContext.routerState.pathParameters);
11381143
}
11391144
}
11401145

packages/go_router/test/go_router_test.dart

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,6 +3956,50 @@ void main() {
39563956
expect(statefulWidgetKey.currentState?.counter, equals(0));
39573957
});
39583958

3959+
testWidgets(
3960+
'Navigates to correct nested navigation tree in StatefulShellRoute '
3961+
'and maintains path parameters', (WidgetTester tester) async {
3962+
StatefulNavigationShell? routeState;
3963+
3964+
final List<RouteBase> routes = <RouteBase>[
3965+
GoRoute(
3966+
path: '/:id',
3967+
builder: (_, __) => const Placeholder(),
3968+
routes: <RouteBase>[
3969+
StatefulShellRoute.indexedStack(
3970+
builder: (BuildContext context, GoRouterState state,
3971+
StatefulNavigationShell navigationShell) {
3972+
routeState = navigationShell;
3973+
return navigationShell;
3974+
},
3975+
branches: <StatefulShellBranch>[
3976+
StatefulShellBranch(routes: <GoRoute>[
3977+
GoRoute(
3978+
path: 'a',
3979+
builder: (BuildContext context, GoRouterState state) =>
3980+
Text('a id is ${state.pathParameters['id']}'),
3981+
),
3982+
]),
3983+
StatefulShellBranch(routes: <GoRoute>[
3984+
GoRoute(
3985+
path: 'b',
3986+
builder: (BuildContext context, GoRouterState state) =>
3987+
Text('b id is ${state.pathParameters['id']}'),
3988+
),
3989+
]),
3990+
],
3991+
),
3992+
])
3993+
];
3994+
3995+
await createRouter(routes, tester, initialLocation: '/123/a');
3996+
expect(find.text('a id is 123'), findsOneWidget);
3997+
3998+
routeState!.goBranch(1);
3999+
await tester.pumpAndSettle();
4000+
expect(find.text('b id is 123'), findsOneWidget);
4001+
});
4002+
39594003
testWidgets('Maintains state for nested StatefulShellRoute',
39604004
(WidgetTester tester) async {
39614005
final GlobalKey<NavigatorState> rootNavigatorKey =

0 commit comments

Comments
 (0)