Skip to content

Commit

Permalink
Merge pull request #21 from harkairt/fix/do-not-throw-without-name
Browse files Browse the repository at this point in the history
fix: do not throw for ShellRoutes not having name
  • Loading branch information
harkairt authored Nov 20, 2024
2 parents bbc8eed + ebd09e8 commit ab655d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/guarded_go_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class GuardedGoRouter {
subordinateRoutes
.map((e) {
if (e is! GoRoute) {
throw "This should be a GoRoute";
return null;
}
return e.name;
})
Expand Down
26 changes: 26 additions & 0 deletions test/guarded_go_router_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,32 @@ void main() {
guard2 = Guard2();
});

testWidgets("allow having a shell route as a direct child of it", (WidgetTester tester) async {
reset(guard1);
deactivateGuard(guard: guard1);

final router = await pumpRouter(
tester,
guards: [guard1],
routes: [
_goRoute("shield1", shieldOf: [Guard1]),
_discardShell<Guard1>([
ShellRoute(
routes: [
_goRoute("3"),
],
),
]),
_goRoute("followUp1", followUp: [Guard1]),
],
);

router.goNamed("3");

await tester.pumpAndSettle();
expect(router.location.sanitized, "/followUp1");
});

group('any() blocks', () {
setUp(() {
reset(guard1);
Expand Down

0 comments on commit ab655d2

Please sign in to comment.