Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

How to use multi values of provider in one Widget? #17

Open
lanistor opened this issue Jul 10, 2019 · 5 comments
Open

How to use multi values of provider in one Widget? #17

lanistor opened this issue Jul 10, 2019 · 5 comments

Comments

@lanistor
Copy link

lanistor commented Jul 10, 2019

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)
    );
@hlhr202
Copy link

hlhr202 commented Jul 11, 2019

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

@lanistor
Copy link
Author

@hlhr202 Still cannot.

@bigzhu
Copy link

bigzhu commented Aug 24, 2019

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

@filiph
Copy link
Contributor

filiph commented Aug 27, 2019

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: #3 (comment). 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.

@bigzhu
Copy link

bigzhu commented Aug 28, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants