Skip to content

Commit

Permalink
[go_router] Add preload parameter to `StatefulShellBranchData.$bran…
Browse files Browse the repository at this point in the history
…ch` (#8545)

Part of flutter/flutter#162055

The parameter will be used by `go_router_builder`
  • Loading branch information
ValentinVignal authored Feb 7, 2025
1 parent 24d6d9c commit 970d858
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/go_router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 14.8.0

- Adds `preload` parameter to `StatefulShellBranchData.$branch`.

## 14.7.2

- Add missing `await` keyword to `onTap` callback in `navigation.md`.
Expand Down
2 changes: 2 additions & 0 deletions packages/go_router/lib/src/route_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,15 @@ abstract class StatefulShellBranchData {
List<NavigatorObserver>? observers,
String? initialLocation,
String? restorationScopeId,
bool preload = false,
}) {
return StatefulShellBranch(
routes: routes,
navigatorKey: navigatorKey,
observers: observers,
initialLocation: initialLocation,
restorationScopeId: restorationScopeId,
preload: preload,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: go_router
description: A declarative router for Flutter based on Navigation 2 supporting
deep linking, data-driven routes and more
version: 14.7.2
version: 14.8.0
repository: https://github.com/flutter/packages/tree/main/packages/go_router
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22

Expand Down
15 changes: 15 additions & 0 deletions packages/go_router/test/route_data_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,21 @@ void main() {
});
});

group('StatefulShellBranchData', () {
test('Can assign preload', () {
final StatefulShellBranch branch = StatefulShellBranchData.$branch(
preload: true,
routes: <RouteBase>[
GoRouteData.$route(
path: '/child',
factory: (GoRouterState state) => const _GoRouteDataBuild(),
),
],
);
expect(branch.preload, true);
});
});

testWidgets(
'It should redirect using the overridden redirect method',
(WidgetTester tester) async {
Expand Down

0 comments on commit 970d858

Please sign in to comment.