In flutter bloc if i need to use multi bloc listener to make bloc to bloc communitication , should i use multi bloc provider?
Asked
Active
Viewed 508 times
-1
-
mulTiBlocProvider is just a shortcut, see its code to understand it – Jscti Oct 12 '21 at 07:24
-
please write your question again @Winter – Jscti Oct 12 '21 at 07:42
1 Answers
0
You can use MultiBlocProvider
to pass one bloc
into another bloc
like this:
MultiBlocProvider(
providers: [
BlocProvider<FirstBloc>(
create: (BuildContext context) => FirstBloc(),
),
BlocProvider<SecondBloc>(
create: (BuildContext context) => SecondBloc(
firstBloc: BlocProvider.of<FirstBloc>(context),
...
),
),
],
child: App(),
);

Bach
- 2,928
- 1
- 6
- 16