-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[go_router]Fixes GoRouterState.location and GoRouterState.param to return correct value #2786
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
Conversation
027776a
to
353d255
Compare
Does it also fixes wrong GoRouterState (accessed using GoRouteState.of(context)) when using router.push ? |
I am not aware of the issue, is there an existing github issue? if not, can you file a new issue for this? |
Ok. let me try to reproduce on a simple test case. |
here we go: flutter/flutter#114901 |
@@ -20,74 +20,95 @@ class RouteConfiguration { | |||
required this.redirectLimit, | |||
required this.topRedirect, | |||
required this.navigatorKey, | |||
}) { | |||
}) : assert(_debugCheckPath(routes, true)), |
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.
all RouteBase integrity check will be here, instead of separated in different constructor
|
||
/// The route match that represent route pushed through [GoRouter.push]. | ||
// TODO(chunhtai): Removes this once imperative API no longer insert route match. | ||
class ImperativeRouteMatch extends RouteMatch { |
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.
This is a workaround that should be removed once the imperative API refactor is done
// If there are multiple routes that match the location, returning the first one. | ||
// To make predefined routes to take precedence over dynamic routes eg. '/:id' | ||
// consider adding the dynamic route at the end of the routes | ||
return result.first; |
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.
This always returns first, might as well use a single object to hold the result. This is probably some left over code from previous refactoring.
eab4a9d
to
08ca9cb
Compare
@chunhtai so now to access the latest values via |
you can do |
@chunhtai I fixed the merge conflicts with master, but a few of the |
38949ac
to
574b8b9
Compare
f895f3e
to
ce2f4be
Compare
@@ -77,7 +78,7 @@ class RouteBuilder { | |||
return _buildErrorNavigator( | |||
context, | |||
e, | |||
Uri.parse(matchList.location.toString()), | |||
Uri.parse(matchList.uri.toString()), |
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.
can't this entire line be just matchList.uri
?
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.
nice catch
@chunhtai are there any plans to expose |
@ahmednfwela yes, that will be my next step. I will open up most of the internal classes. |
fixes flutter/flutter#112444
fixes flutter/flutter#111040
also cleans up RouteMatch and RouteMatchlist. This pr move all the properties in RouteMatch class that are the same for all of RouteMatch to RouteMatchlist to avoid duplicating data too many time.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.