-
-
Notifications
You must be signed in to change notification settings - Fork 512
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 vs Provider lint? #102
Comments
One idea is to have a linter hint which would fire when you have an instance of ChangeNotifier as the value provided by the vanilla |
I'm mixed about the linter. It is a good idea but may not be used. The main issue with custom analyzer plug-ins is that they require a separate installation step beside the From my experience, most people don't know/have an |
One alternative is to add an assert on There's technically a use-case for it as we're speaking, but:
|
This is an health check to ensure that the listenable objects are indeed listened. closes #102
I think linter is a good idea |
I think linter is a better idea. I always use Provider to perform all kinds of dependency injection, including injecting Setting a global |
A linter is very time-consuming to implement and the custom lint API makes it that most users would not install the linter, rendering it not very useful. |
I think a linter plugin(like Working with Plugins) would be the best option, but I'm not sure there is such a possibility now |
There's nothing close to true plug-ins in dart. There's something WIP, but that consumes a lot of resources (plug-ins have to re-analyze the project). They don't work with "dart analyze" or // ignore. And they need to be installed separately |
I understand you, I am now thinking about implementation using code generation, but I agree that there are many problems |
What about an optional parameter inside the Provider constructor, say |
Someone just showed me
provider
code that didn't work for them — things were getting updated internally, theChangeNotifier
was callingnotifyListeners
, the widget was correctly wrapped in a relevantConsumer
, there were no static or dynamic errors, but nothing changed in the UI.The culprit, which took me several minutes to realize, was using
Provider
instead ofChangeNotifierProvider
.I don't think there is an easy solution for this, but I thought maybe others would have ideas.
The text was updated successfully, but these errors were encountered: