flutter-provide icon indicating copy to clipboard operation
flutter-provide copied to clipboard

How to use multi values of provider in one Widget?

Open lanistor opened this issue 6 years ago • 5 comments

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)
    );

lanistor avatar Jul 10 '19 08:07 lanistor

Hey checkout the example here https://github.com/hlhr202/FlutterStatePOC

hlhr202 avatar Jul 11 '19 07:07 hlhr202

@hlhr202 Still cannot.

lanistor avatar Jul 11 '19 09:07 lanistor

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

bigzhu avatar Aug 24 '19 14:08 bigzhu

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.

filiph avatar Aug 27 '19 22:08 filiph

Maybe change to use https://pub.dev/packages/provider is the better choice.

bigzhu avatar Aug 28 '19 14:08 bigzhu