-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[go_router] Fix replace routes hanging the originating completer #9332
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?
Conversation
@nouvist LGTM, thank you for submitting the fix, I was facing the same issue |
@@ -168,6 +168,18 @@ class GoRouteInformationParser extends RouteInformationParser<RouteMatchList> { | |||
return redirectedFuture; | |||
} | |||
|
|||
/// Ensures the replacement routes can resolve the originating route completer. | |||
Completer<T?>? _createInheritedCompleter<T>( |
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.
What if the type T mismatched for the new route and the old route. Instead of inherited the completer, I think it should resolve the previous route's future because it is replaced.
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.
Yeah, that's the problem, but I still think resolve the completer when the replacement pops up is my preferred, as the waiting route can hold until its screen reappears.
I propose, what if the push
(etc) had a mapReplacementResult
? But it may need to be on RouteInformationState
and ImperativeRouteMatch
, which I'm not sure if there will be breaking changes or not.
fbe167b
to
f8f51c6
Compare
Both are used to resolve the current route completer when it is replaced. Both are added to `RouteInformationState` and `ImperativeRouteMatch`.
The behavior of
replace
andpushReplacement
involves popping the last route and ignoring the completer, leaving the last route's future unresolved. This PR introduces new behavior for both methods to inherit the last route's completer if the last route is anImperativeRouteMatch
.Expected issue(s) should be fixed by this:
GoRoute.push()
is not resolving when the push page gets replaced via pushReplacement flutter#141251Previous behavior:
sebelum.mp4
This PR behavior:
sesudah.mp4
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3