Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
990c293
implemented helpers for StatefulShellRoute
hannah-hyj Jun 16, 2023
4918014
Merge branch 'main' into statefulshellroute
hannah-hyj Jun 16, 2023
c6bde6d
lint
hannah-hyj Jun 16, 2023
52ce037
Update route_data.dart
hannah-hyj Jun 16, 2023
b9c8080
lint
hannah-hyj Jun 16, 2023
9005a8c
Update route_data.dart
hannah-hyj Jun 16, 2023
8cf69b6
update
hannah-hyj Jun 26, 2023
5963020
resolve comments
hannah-hyj Jun 28, 2023
4f60cd6
1
hannah-hyj Jun 16, 2023
e4fc526
Revert "1"
hannah-hyj Jun 16, 2023
d328021
update
hannah-hyj Jun 26, 2023
bc19f53
update tests
hannah-hyj Jun 28, 2023
f827680
Merge branch 'main' of https://github.com/flutter/packages into build…
hannah-hyj Jul 9, 2023
6a09020
update
hannah-hyj Jul 10, 2023
bb6064b
bump version
hannah-hyj Jul 10, 2023
441eb78
Update route_config.dart
hannah-hyj Jul 10, 2023
8b4e2de
Update stateful_shell_route_test.dart
hannah-hyj Jul 10, 2023
a2ef5d2
Merge branch 'main' of https://github.com/flutter/packages into build…
hannah-hyj Jul 12, 2023
13865ac
update route_config
hannah-hyj Jul 12, 2023
e3d109d
Update route_config.dart
hannah-hyj Jul 19, 2023
51ae0a0
Merge branch 'main' of https://github.com/flutter/packages into build…
hannah-hyj Jul 19, 2023
bfd36ef
merge
hannah-hyj Jul 20, 2023
03c069b
resolve comments
hannah-hyj Jul 25, 2023
0da2339
update
hannah-hyj Jul 25, 2023
06c7e67
Update route_config.dart
hannah-hyj Jul 25, 2023
ecbc5f5
update
hannah-hyj Jul 31, 2023
9808f62
Merge branch 'main' of https://github.com/flutter/packages into build…
hannah-hyj Jul 31, 2023
6044e32
Update pubspec.yaml
hannah-hyj Jul 31, 2023
3c2ed3b
lint
hannah-hyj Jul 31, 2023
1e78def
Update stateful_shell_route_example.dart
hannah-hyj Jul 31, 2023
eecb67e
Update pubspec.yaml
hannah-hyj Jul 31, 2023
2e63519
Update pubspec.yaml
hannah-hyj Jul 31, 2023
cfb1de8
Update stateful_shell_route_example.dart
hannah-hyj Jul 31, 2023
7fa8523
Merge branch 'main' into builder-stateful
hannah-hyj Aug 2, 2023
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
Prev Previous commit
Next Next commit
resolve comments
  • Loading branch information
hannah-hyj committed Jun 28, 2023
commit 5963020937a7763ff58f0f2f87cb03ea6c4ec258
8 changes: 0 additions & 8 deletions packages/go_router/lib/src/route_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@ abstract class ShellRouteData extends RouteData {
List<RouteBase> routes = const <RouteBase>[],
}) {
T factoryImpl(GoRouterState state) {
final Object? extra = state.extra;

// If the "extra" value is of type `T` then we know it's the source
// instance of `ShellRouteData`, so it doesn't need to be recreated.
if (extra is T) {
return extra;
}

return (_stateObjectExpando[state] ??= factory(state)) as T;
}

Expand Down
58 changes: 10 additions & 48 deletions packages/go_router/test/route_data_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,14 @@ final ShellRoute _shellRouteDataPageBuilder = ShellRouteData.$route(
],
);

class _StatefulShellBranchDataBuilder extends StatefulShellBranchData {
const _StatefulShellBranchDataBuilder();
}

class _StatefulShellRouteDataBuilder extends StatefulShellRouteData {
const _StatefulShellRouteDataBuilder();

@override
Widget builder(
BuildContext context,
GoRouterState state,
Widget navigator,
StatefulNavigationShell navigator,
) =>
SizedBox(
key: const Key('builder'),
Expand All @@ -110,7 +106,6 @@ final StatefulShellRoute _statefulShellRouteDataBuilder =
factory: (GoRouterState state) => const _StatefulShellRouteDataBuilder(),
branches: <StatefulShellBranch>[
StatefulShellBranchData.$branch(
factory: (GoRouterState state) => const _StatefulShellBranchDataBuilder(),
routes: <RouteBase>[
GoRouteData.$route(
path: '/child',
Expand All @@ -128,7 +123,7 @@ class _StatefulShellRouteDataPageBuilder extends StatefulShellRouteData {
Page<void> pageBuilder(
BuildContext context,
GoRouterState state,
Widget navigator,
StatefulNavigationShell navigator,
) =>
MaterialPage<void>(
child: SizedBox(
Expand All @@ -143,7 +138,6 @@ final StatefulShellRoute _statefulShellRouteDataPageBuilder =
factory: (GoRouterState state) => const _StatefulShellRouteDataPageBuilder(),
branches: <StatefulShellBranch>[
StatefulShellBranchData.$branch(
factory: (GoRouterState state) => const _StatefulShellBranchDataBuilder(),
routes: <RouteBase>[
GoRouteData.$route(
path: '/child',
Expand Down Expand Up @@ -181,11 +175,7 @@ void main() {
initialLocation: '/build',
routes: _routes,
);
await tester.pumpWidget(MaterialApp.router(
routeInformationProvider: goRouter.routeInformationProvider,
routeInformationParser: goRouter.routeInformationParser,
routerDelegate: goRouter.routerDelegate,
));
await tester.pumpWidget(MaterialApp.router(routerConfig: goRouter));
expect(find.byKey(const Key('build')), findsOneWidget);
expect(find.byKey(const Key('buildPage')), findsNothing);
},
Expand All @@ -198,11 +188,7 @@ void main() {
initialLocation: '/build-page',
routes: _routes,
);
await tester.pumpWidget(MaterialApp.router(
routeInformationProvider: goRouter.routeInformationProvider,
routeInformationParser: goRouter.routeInformationParser,
routerDelegate: goRouter.routerDelegate,
));
await tester.pumpWidget(MaterialApp.router(routerConfig: goRouter));
expect(find.byKey(const Key('build')), findsNothing);
expect(find.byKey(const Key('buildPage')), findsOneWidget);
},
Expand All @@ -219,11 +205,7 @@ void main() {
_shellRouteDataBuilder,
],
);
await tester.pumpWidget(MaterialApp.router(
routeInformationProvider: goRouter.routeInformationProvider,
routeInformationParser: goRouter.routeInformationParser,
routerDelegate: goRouter.routerDelegate,
));
await tester.pumpWidget(MaterialApp.router(routerConfig: goRouter));
expect(find.byKey(const Key('builder')), findsOneWidget);
expect(find.byKey(const Key('page-builder')), findsNothing);
},
Expand All @@ -238,11 +220,7 @@ void main() {
_shellRouteDataPageBuilder,
],
);
await tester.pumpWidget(MaterialApp.router(
routeInformationProvider: goRouter.routeInformationProvider,
routeInformationParser: goRouter.routeInformationParser,
routerDelegate: goRouter.routerDelegate,
));
await tester.pumpWidget(MaterialApp.router(routerConfig: goRouter));
expect(find.byKey(const Key('builder')), findsNothing);
expect(find.byKey(const Key('page-builder')), findsOneWidget);
},
Expand All @@ -259,11 +237,7 @@ void main() {
_statefulShellRouteDataBuilder,
],
);
await tester.pumpWidget(MaterialApp.router(
routeInformationProvider: goRouter.routeInformationProvider,
routeInformationParser: goRouter.routeInformationParser,
routerDelegate: goRouter.routerDelegate,
));
await tester.pumpWidget(MaterialApp.router(routerConfig: goRouter));
expect(find.byKey(const Key('builder')), findsOneWidget);
expect(find.byKey(const Key('page-builder')), findsNothing);
},
Expand All @@ -278,11 +252,7 @@ void main() {
_statefulShellRouteDataPageBuilder,
],
);
await tester.pumpWidget(MaterialApp.router(
routeInformationProvider: goRouter.routeInformationProvider,
routeInformationParser: goRouter.routeInformationParser,
routerDelegate: goRouter.routerDelegate,
));
await tester.pumpWidget(MaterialApp.router(routerConfig: goRouter));
expect(find.byKey(const Key('builder')), findsNothing);
expect(find.byKey(const Key('page-builder')), findsOneWidget);
},
Expand All @@ -296,11 +266,7 @@ void main() {
initialLocation: '/redirect',
routes: _routes,
);
await tester.pumpWidget(MaterialApp.router(
routeInformationProvider: goRouter.routeInformationProvider,
routeInformationParser: goRouter.routeInformationParser,
routerDelegate: goRouter.routerDelegate,
));
await tester.pumpWidget(MaterialApp.router(routerConfig: goRouter));
expect(find.byKey(const Key('build')), findsNothing);
expect(find.byKey(const Key('buildPage')), findsOneWidget);
},
Expand All @@ -313,11 +279,7 @@ void main() {
initialLocation: '/redirect-with-state',
routes: _routes,
);
await tester.pumpWidget(MaterialApp.router(
routeInformationProvider: goRouter.routeInformationProvider,
routeInformationParser: goRouter.routeInformationParser,
routerDelegate: goRouter.routerDelegate,
));
await tester.pumpWidget(MaterialApp.router(routerConfig: goRouter));
expect(find.byKey(const Key('build')), findsNothing);
expect(find.byKey(const Key('buildPage')), findsNothing);
},
Expand Down