-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[go_router] docs: Document regex constraints on path parameters (flutter#177766) #11722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -361,6 +361,15 @@ class GoRoute extends RouteBase { | |||||||||
| /// `/family/456` and etc. The parameter values are stored in [GoRouterState] | ||||||||||
| /// that are passed into [pageBuilder] and [builder]. | ||||||||||
| /// | ||||||||||
| /// A path parameter may optionally be constrained to a regular expression | ||||||||||
| /// by appending the expression in parentheses after the parameter name: | ||||||||||
| /// `:paramName(regex)`. The parameter only matches if the corresponding path | ||||||||||
| /// segment also matches the regular expression — segments that fail the | ||||||||||
| /// pattern fall through to other route candidates. For example, | ||||||||||
| /// `/users/:id(\d+)` matches `/users/42` but not `/users/alice`. The | ||||||||||
| /// expression must not introduce its own capturing groups; everything | ||||||||||
| /// between the parentheses is interpreted as a Dart [RegExp] body. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation of the path parser (
Suggested change
|
||||||||||
| /// | ||||||||||
| /// The query parameter are also capture during the route parsing and stored | ||||||||||
| /// in [GoRouterState]. | ||||||||||
| /// | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example path contains a backslash (
\d). In Dart, this requires using a raw string literal or escaping the backslash to avoid an 'Invalid escape sequence' error. Using the raw string prefixrin the documentation makes the example more accurate and easier for developers to use directly.