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

ChangeNotifierProvider example #51

Closed
stocksp opened this issue May 3, 2019 · 4 comments
Closed

ChangeNotifierProvider example #51

stocksp opened this issue May 3, 2019 · 4 comments

Comments

@stocksp
Copy link

stocksp commented May 3, 2019

Is the example code show by @brianegan in "Merge provider and scoped_model"
brianegan/scoped_model#61 the "correct" way to use this provider?

Simple examples of the existing providers would help a lot for users of "scoped_model". Your only example of the 'simple' provider seems to me to be the least useful as it isn't 'reactive' (if I'm reading the docs correctly)

thanks for all your work!

@rrousselGit
Copy link
Owner

All providers are reactive. ChangeNotifierProvider is built on the top of the one in the example.

Improving the documentation and making great examples is definitely needed. But note that, as opposed to scoped_model, there's not a single possible architecture using provider.

provider is a mean, not the end.

@stocksp
Copy link
Author

stocksp commented May 3, 2019

"This is perfect for exposing a complex object that never changes over time without writing a StatefulWidget"
never change .. is where I got the 'non reactive' thought.
In Scoped_model we extend out model from the included Model class and call 'notifyListeners' to get reactivity. Which is the source of my confusion.

@rrousselGit
Copy link
Owner

never changes over time

That's for the default constructor.
Provider.value constructor properly updates dependents when the value changes.

The mean to achieve the update is different though. Instead of a Listenable/ChangeNotifer, you'll need a stateful widget and call setState to update the passed value.

@stocksp
Copy link
Author

stocksp commented May 3, 2019

Ahhh ...
"The mean to achieve the update is different though. Instead of a Listenable/ChangeNotifer, you'll need a stateful widget and call setState to update the passed value."

thanks, got it now!

@stocksp stocksp closed this as completed May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants