Reputation: 415
I'm using Cubits for state management in my Flutter app.
It is my favourite state-management approach so far.
However, I now want to get a little more complex, and have multiple cubits, controlling different bits of state each (eg. one is for login-related state, another for config/settings state, and another for the main app state).
I'm trying to find an example of how to do multiple cubits and I'm not finding anything.
With the BLoc approach we would use MultiBlocProvider.
Is there an equivalent to the MultiBlocProvider for cubits?
Or, can you point me at a tutorial that demonstrates using multiple cubits in the one app?
Upvotes: 4
Views: 5614
Reputation: 315
you can use MultiBlocProvider for cubits and you will not have any problems.
MultiBlocProvider(
providers: [
BlocProvider(
create: (BuildContext context) => MyCubit())
],
child: Container())
you will probably need Bloc-to-Bloc Communication too
these bloc example projects, which use multiple blocs and cubits in a project that may help you. flutter_todos, flutter_shopping_cart, flutter_firebase_login
Upvotes: 4