frideos_examples icon indicating copy to clipboard operation
frideos_examples copied to clipboard

Generic bloc provider

Open gitflutter opened this issue 6 years ago • 3 comments

hi

How to use generic bloc provider with this library? can you please explain ?

Thanks

gitflutter avatar May 17 '19 20:05 gitflutter

Hello @gitflutter, checkout this example where you can find a generic bloc provider providing differents blocs: basics example.

frideosapps avatar May 18 '19 18:05 frideosapps

what else if we have multiple blocs. Say I have 15 blocs ? Should I import all 15 blocs in main page ? if We do like this any issues ?

gitflutter avatar May 21 '19 10:05 gitflutter

You can import the blocs where you need it. If you use a provider the bloc is initialized before you pushing the screen and disposed when you leave it, so there is no issue if you have a lot of blocs. If you don't mind about leaving all in memory, you can also extend the AppStateModel class and declare all the blocs you need in that instance, then with the AppStateProvider you can provide the state of the app (and so every blocs that you declared) to every widget.

frideosapps avatar May 21 '19 16:05 frideosapps