Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 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 @@
## 4.2.2

- Add test extra parameter

## 4.2.1

- Refactors internal classes and methods
Expand Down
1 change: 1 addition & 0 deletions packages/go_router/lib/src/redirection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ RouteMatchList redirect(RouteMatchList prevMatchList,
name: top.route.name,
path: top.route.path,
fullpath: top.fullpath,
extra: top.extra,
params: top.decodedParams,
queryParams: top.queryParams,
),
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: 4.2.1
version: 4.2.2
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
40 changes: 40 additions & 0 deletions packages/go_router/test/go_router_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,46 @@ void main() {
(router.screenFor(matches.first) as TestErrorScreen).ex, isNotNull);
log.info((router.screenFor(matches.first) as TestErrorScreen).ex);
});

testWidgets('extra not null in redirect', (WidgetTester tester) async {
final List<GoRoute> routes = <GoRoute>[
GoRoute(
name: 'home',
path: '/',
builder: (BuildContext context, GoRouterState state) =>
const HomeScreen(),
routes: <GoRoute>[
GoRoute(
name: 'login',
path: 'login',
builder: (BuildContext context, GoRouterState state) {
return const LoginScreen();
},
redirect: (GoRouterState state) {
expect(state.extra, isNotNull);
return null;
},
routes: <GoRoute>[],
),
],
),
];

final GoRouter router = await createRouter(
routes,
tester,
redirect: (GoRouterState state) {
if (state.location == '/login') {
expect(state.extra, isNotNull);
}

return null;
},
);

router.go('/login', extra: 1);
await tester.pump();
});
});

group('initial location', () {
Expand Down