Skip to content

Commit 970d858

Browse files
[go_router] Add preload parameter to StatefulShellBranchData.$branch (#8545)
Part of flutter/flutter#162055 The parameter will be used by `go_router_builder`
1 parent 24d6d9c commit 970d858

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

packages/go_router/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 14.8.0
2+
3+
- Adds `preload` parameter to `StatefulShellBranchData.$branch`.
4+
15
## 14.7.2
26

37
- Add missing `await` keyword to `onTap` callback in `navigation.md`.

packages/go_router/lib/src/route_data.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,15 @@ abstract class StatefulShellBranchData {
342342
List<NavigatorObserver>? observers,
343343
String? initialLocation,
344344
String? restorationScopeId,
345+
bool preload = false,
345346
}) {
346347
return StatefulShellBranch(
347348
routes: routes,
348349
navigatorKey: navigatorKey,
349350
observers: observers,
350351
initialLocation: initialLocation,
351352
restorationScopeId: restorationScopeId,
353+
preload: preload,
352354
);
353355
}
354356
}

packages/go_router/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: go_router
22
description: A declarative router for Flutter based on Navigation 2 supporting
33
deep linking, data-driven routes and more
4-
version: 14.7.2
4+
version: 14.8.0
55
repository: https://github.com/flutter/packages/tree/main/packages/go_router
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22
77

packages/go_router/test/route_data_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,21 @@ void main() {
420420
});
421421
});
422422

423+
group('StatefulShellBranchData', () {
424+
test('Can assign preload', () {
425+
final StatefulShellBranch branch = StatefulShellBranchData.$branch(
426+
preload: true,
427+
routes: <RouteBase>[
428+
GoRouteData.$route(
429+
path: '/child',
430+
factory: (GoRouterState state) => const _GoRouteDataBuild(),
431+
),
432+
],
433+
);
434+
expect(branch.preload, true);
435+
});
436+
});
437+
423438
testWidgets(
424439
'It should redirect using the overridden redirect method',
425440
(WidgetTester tester) async {

0 commit comments

Comments
 (0)