Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[go_router] Add preload parameter to StatefulShellBranchData.$branch #8545

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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