Repository navigation
Commit 1448f08
authored
[go_router] Add BlockedInitialNavigationException for blocked initial deep links (#12213)
When `onEnter` returns `Block.stop()` on the very first navigation attempt (e.g. a deep link on web, before any route has been committed), the parser's `onCanNotEnter` path has no prior configuration to restore and reports a generic `GoException`. Apps handling this in `onException` can't tell "initial deep link blocked" apart from other routing errors (unmatched routes, redirect loops) without string matching on the exception message.
This adds `BlockedInitialNavigationException extends GoException`, raised specifically in that no-prior-route path. It only refines the exception type — no change to when or whether an exception is thrown, and existing `is GoException` checks keep working. Apps can now write `if (state.error is BlockedInitialNavigationException)` in `onException` and, for example, redirect to a loading screen with the deep link preserved instead of treating it as a 404.
Test: widget test in `on_enter_test.dart` — initial navigation blocked by `Block.stop()` with an `onException` handler; asserts the captured `state.error` is a `BlockedInitialNavigationException` (and still a `GoException`).
Fixes flutter/flutter#189581
## Pre-Review Checklist
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.1 parent b0d355f commit 1448f08
4 files changed
Lines changed: 46 additions & 1 deletion
File tree
- packages/go_router
- lib/src
- misc
- pending_changelogs
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
868 | 868 | | |
869 | 869 | | |
870 | 870 | | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
871 | 902 | | |
872 | 903 | | |
873 | 904 | | |
| |||
0 commit comments