-
Notifications
You must be signed in to change notification settings - Fork 77
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
Merge "provider" and "scoped_model" #61
Comments
Thanks, @rrousselGit! Overall, I really like your Pros
Cons
Questions for the community
|
My main concern is that currently, we have many duplicates. I don't see it as being sustainable. It's confusing and splits the community effort across many packages for no reason.
Considering more than half of the points in pros represents an issue on About breaking changes, I think it is possible to merge This is ultimately just widgets with different names. We could replace the implementation of The only technical difference is |
Agreed. I think the question might become: In that case, should we merge the features of I'd agree the name Therefore, I think keeping To clarify the plan:
This would allow a very nice upgrade path for folks while giving those who need the extra functionality immediate access. We could also collaborate together more on features in the core lib from that point on. |
Hi @brianegan , I just switched my apps from using BTW, another state management package provide was just released. Too many options in community now, and hope again the state management solution can get relatively unified ASAP. |
Great discussion here! I'd like to point to a related discussion. The "ScopedModel v2" from Fuchsia is now open sourced as https://github.com/google/flutter-provide, and on pub as I don't have an answer yet and I'd like Eric and I to ponder our options. I do think Remi's package is fantastic. I also like the simplicity of ScopedModel / provide. For example, I agree with Brian that There is value in choice but there is also value in one (potentially "official") starting point. Please keep the discussion going. |
Hi @filiph , you called provide as "ScopedModel v2", I was wondering why you didn't upgrade this original scoped_model to V2 and try to keep backward compatibility, which will give flexibility to community to use a unified package. Agree with this:
If provide is considered as an official package, maybe put it into organisation flutter is better? In one word, relatively unified/stable(understand 100% unify never happens, also should allow different choices) is good for community. |
The dependency on But if |
@brianegan @rrousselGit @filiph Any updates on the direction of your efforts in the scoped_model arena. Where should we direct people? Would be nice to keep the community updated on any future intentions, and excited to see a concerted effort. |
The super Marvel - DC power of scoped_model is simplicity. Is understanding docs with snap photographic reading and using with a straight simple way. For more complexity, obfuscating code, no life go for Bloc, redux. So keep it as is |
@halfahad IMO, it makes sense to merge these projects. Remi is working on v2, which removes the dependency on flutter_hooks. Once that's in place and the API has a couple of months to stabilize, I'll encourage folks to move over. @xalikoutis Thanks for the input. Overall, while Provider offers extra functionality, I think it can be just as simple :) Here's a translation of the Counter app in the readme to use // Extend ChangeNotifier instead of Model.
// ChangeNotifier is part of Flutter and works the same way as model!
class CounterModel extends ChangeNotifier {
int _counter = 0;
int get counter => _counter;
void increment() {
_counter++;
notifyListeners();
}
}
class CounterApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Use the ChangeNotifierProvider Widget instead of ScopedModel
return ChangeNotifierProvider<CounterModel>.stateful(
builder: () => CounterModel(),
child: Column(children: [
// Use Consumer instead of ScopedModelDescendant
Consumer<CounterModel>(
builder: (context, model) => Text('${model.counter}'),
),
new Text("Another widget that doesn't depend on the CounterModel")
])
);
}
} |
@rrousselGit now that provider 2.0 is out, can you update the last example from @brianegan ? |
Sure~ // Extend ChangeNotifier instead of Model.
// ChangeNotifier is part of Flutter and works the same way as model!
class CounterModel extends ChangeNotifier {
int _counter = 0;
int get counter => _counter;
void increment() {
_counter++;
notifyListeners();
}
}
class CounterApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Use the ChangeNotifierProvider Widget instead of ScopedModel
return ChangeNotifierProvider<CounterModel>(
builder: (_) => CounterModel(),
child: Column(children: [
// Use Consumer instead of ScopedModelDescendant
Consumer<CounterModel>(
builder: (context, model, _) => Text('${model.counter}'),
),
new Text("Another widget that doesn't depend on the CounterModel")
])
);
}
} |
ScopedModel user here. Using it in a pretty complex app and IMHO there’s no need to merge it with Provider (which itself looks awesome. I think I would have used it instead of ScopedModel if it were available in December 2018). |
Thanks for the feedback, @kbrmimbyl! |
Previously ScopedModel User here. Today I just run in several issues I am not able to explain to myself. Since the google map wasn't that necessary, I could just remove it. On an other front panel I used an image grid with a plus button for image selection & upload. In both cases no error messages or stack traces. Migrating to provider seems to fix the issue. |
provider is an alternative to inherited widgets management.
Both
provider
andscoped_model
aims at doing the same thing, whichprovider
having a slightly larger vision:provider
is not limited to exposing aModel
and works with potentially anything, including BLoC, streams, and others.On the other hand,
scoped_model
is a lot more popular thanprovider
.The state of things is pretty confusing for the community.
scoped_model
is not enough for advanced inherited widgets, butprovider
has a too small reach for peoples to find the package.Would this make sense to merge both packages?
provider
already implements the same features asscoped_model
but with different names.provider
could expose aliases of its implementations to matchscoped_model
names to make the merging non-breaking.The text was updated successfully, but these errors were encountered: