-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Passing providers between widgets in a sequence doesn't work #148625
Comments
Hi, I believe I have solved it. The MultiProvider needed to be set within the context callback in the navigator push:
However, this feels counter-intuitive to me. Why can't the MultiProvider be defined outside of the navigator push? Correct me if I'm wrong but the context isn't used if the MultiProvider is defined without one. It's only when it's rendered that a context is used, for example in a navigator push. |
You may file a proposal issue to make changes as suggested so that it can be tracked and address separately. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to reproduce
(If you know of an easier alternative way to approach this problem, I'm all ears -- but I suspect there may be a Flutter bug in here somewhere so I decided to post here)
This is regarding displaying widgets in a sequence by pushing a new context for each displayed widget, by using a callback, and passing on any desired providers.
params
input parameter.In my case, I am receiving an error that the next widget can't find the provider I've passed on.
Is there maybe some understanding of Provider I'm missing here?
Expected results
The next widget in the sequence should be able to read a provider which it received from the preceding widget in the sequence.
Actual results
The next widget in the sequence is unable to read the provider it received.
Code sample
dartpad:
https://dartpad.dev/?id=698907a09fb9463f34fb42a78d9fd939
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: