Skip to content
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

Returning values from screens? #9

Open
naiveai opened this issue Jun 8, 2019 · 5 comments
Open

Returning values from screens? #9

naiveai opened this issue Jun 8, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@naiveai
Copy link

naiveai commented Jun 8, 2019

Is there a way to return a value from a screen like is demonstrated in https://flutter.dev/docs/cookbook/navigation/returning-data? I know sharing data with the store works, but this also enables the important use case of running some function (like a dispatch to update the state using an async action) whenever a page's back button is pressed.

@esarbanis
Copy link
Collaborator

Hi @naiveai.

Couldn't you achieve the same result if you use a postNavigation function on NavigateToAction.pop?

I can see in that Navigator.pop API includes a result optional parameter, which is returned upon completion, but as the navigation is being done in the NavigationMiddleware the only way to obtain the result is to set it somewhere in your state ... 🤔 This by itself is a bit complicated as it would make the library state aware in order to set the result in it.

A way around it could be to include an optional user-provided callback function, but it needs some thought put into it.

Please let me know if the postNavigation can work for you otherwise, this will require a new feature.

@naiveai
Copy link
Author

naiveai commented Jun 10, 2019

postNavigation is run immediately after the page is navigated to. What I'm talking about is a callback when the navigator page I've just pushed is popped by the user, by pressing the back button. It's what happens when you use .then on the Future returned by a Navigator.push call.

@esarbanis
Copy link
Collaborator

OK I see now. This will require an API change, most probably not a breaking one. Let me see what I can do.

@esarbanis esarbanis self-assigned this Jun 10, 2019
@esarbanis esarbanis added the enhancement New feature or request label Jun 10, 2019
@simkepal
Copy link

Hello,

Was there any change for this? I would also love this feature.

@esarbanis
Copy link
Collaborator

Hi @simkepal unfortunately I didn't have the time to move forward with it, but I will raise its priority and try to have it done as soon as I find the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants