From ba51dddc8d63025a362da96539db387d1d4c0ded Mon Sep 17 00:00:00 2001 From: ValentinVignal Date: Sat, 1 Feb 2025 18:45:51 +0800 Subject: [PATCH 1/3] Add preload parameter for go router builder --- packages/go_router/lib/src/route_data.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/go_router/lib/src/route_data.dart b/packages/go_router/lib/src/route_data.dart index afe6159cecb..a088cc96652 100644 --- a/packages/go_router/lib/src/route_data.dart +++ b/packages/go_router/lib/src/route_data.dart @@ -342,6 +342,7 @@ abstract class StatefulShellBranchData { List? observers, String? initialLocation, String? restorationScopeId, + bool preload = false, }) { return StatefulShellBranch( routes: routes, @@ -349,6 +350,7 @@ abstract class StatefulShellBranchData { observers: observers, initialLocation: initialLocation, restorationScopeId: restorationScopeId, + preload: preload, ); } } From f9afbcb0ec4f6e1d0607a4bed8b5e71c149e5b5b Mon Sep 17 00:00:00 2001 From: ValentinVignal Date: Sat, 1 Feb 2025 18:49:45 +0800 Subject: [PATCH 2/3] Add test --- packages/go_router/test/route_data_test.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/go_router/test/route_data_test.dart b/packages/go_router/test/route_data_test.dart index 1da35a672b6..757b1b054dd 100644 --- a/packages/go_router/test/route_data_test.dart +++ b/packages/go_router/test/route_data_test.dart @@ -420,6 +420,21 @@ void main() { }); }); + group('StatefulShellBranchData', () { + test('Can assign preload', () { + final StatefulShellBranch branch = StatefulShellBranchData.$branch( + preload: true, + routes: [ + 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 { From f551312d4f703d4b7a2b726ba16d67b84289cfb1 Mon Sep 17 00:00:00 2001 From: ValentinVignal Date: Sat, 1 Feb 2025 18:51:34 +0800 Subject: [PATCH 3/3] Update version number --- packages/go_router/CHANGELOG.md | 4 ++++ packages/go_router/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index d51aaf244a3..97d8dfe35c3 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -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`. diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml index 204db07f029..636d2637eb9 100644 --- a/packages/go_router/pubspec.yaml +++ b/packages/go_router/pubspec.yaml @@ -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