How to use multi values of provider in one Widget?
For example: in the code below, how to use counter and switcher in one widget?
Neither Provide.value<T> or StreamBuilder<T> seems to be fited for this.
var counter = Counter();
var switcher = Switcher();
var providers = Providers();
providers
..provide(Provider<Counter>.value(counter))
..provide(Provider<Switcher>.value(switcher));
runApp(
ProviderNode(
child: MyApp(),
providers: providers)
);
Hey checkout the example here https://github.com/hlhr202/FlutterStatePOC
@hlhr202 Still cannot.
like that:
return Provide< Counter >(builder: (context, child, counter) {
return Provide< Switcher >(builder: (context, child, switcher) {
// your can use counter and switcher both here
});
});
the only problem is this code so ugly
Hi @vifird, @hlhr202 and @bigzhu,
Sorry for the complete silence on this issue (and the repo in general). I've been unsure about the future of the provide package but now I've made the decision to let it go: https://github.com/google/flutter-provide/issues/3#issuecomment-525503648. Please comment over at the linked issue if you have a strong desire to keep the development of this package alive (if so, please link to your fork if you have it).
To be clear, the package will always be available at https://pub.dev/packages/provide — pub doesn't allow packages to "disappear". It won't be updated, though.
Maybe change to use https://pub.dev/packages/provider is the better choice.