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
[go_router] Return a value on pop #2416
[go_router] Return a value on pop #2416
Conversation
This reverts commit 06a2ae5.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
To make it easier to use, and also more like Navigator 1.0, I changed the dynamic value to T, T extends Object? so in that way we will always expect a nullable value from a pushAsync or pushNamedAsync. The tests has been updated.
I updated the PR, so now instead of doing: final result = await context.pushNamedAsync(routeName) as bool?;
context.pop(someValue); you can do: final result = await context.pushNamedAsync<bool>(routeName);
context.pop<bool>(someValue); Or even: bool? result = await context.pushNamedAsync(routeName); In both cases the returned value will be nullable. |
Now because we save the completer in the RouteMatch it'll not break when pushing the same screen over and over again |
We should not merge this until we figure out this how to support imperative API moving forward |
wait this issue... |
I know this is a missing feature, and probably a big one. But we would like to do a refactoring on the imperative API which may make this fix obsolete or hard to maintain. Sorry for the inconvenience. |
One should be patient, for the sake of a good API, where flaws are temporary and respectable and rigorous. |
@chunhtai when do you think we can add this feature to go_router? I have a branch with the implementation updated and all the tests ready to be reviewed. Also that code has been in production in multiple apps working flawlessly. |
I currently need to return to the previous page to carry parameters. How should I do it before you merge it? I don’t know how to do it |
I have a package called go_router_flow in pub, it's updated to the last go_router update, returning values work the same as navigator 1.0 |
So we can't get async |
@chunhtai any news? |
I think this is already fixed when i refactor the pop. |
Wich version this will be merged? I can't find this pop in API (6.0.1) |
Right, so now pop can come with a value after @chunhtai refactor. But how can I retrieve this value? Since both push and go return void and void can't be used? Someone understand how this will work? |
hmmm, I mainly added for show dialog and imperative API. We should probably expose return future for gorouter push. |
@chunhtai just to let you know, this PR is outdated. If you want I can make the update. I have another branch with a better/cleaner implementation of this. |
Sure feel free to open a new pr and pin me to review. I think what's left is the push need to return a future |
In this PR I'm adding 2 new methods, pushAsync and pushNamedAsync, that allows you to wait for a value when the widget pushed pops, like in navigator 1.0.
Fixes flutter/flutter#99663.
Fixes flutter/flutter#107217
Fixes flutter/flutter#100969
This PR will not conflict with older versions of go_router when updated.
Here's the link of the document with the changes: https://docs.google.com/document/d/1bcPV8yNAETmlxTFTMpO_JcJ7-yMoF8qaCPa884hFmXA/edit?usp=sharing&resourcekey=0-73tg8sZOVf0YXBmz-MLwQw.
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.