BlocProvider<T extends Bloc>.fromBloc constructor
Pass the bloc which is managed by other widget.
Passed bloc won't be disposed automatically, so it should be managed appropriately.
Typical use case is this:
- The bloc is managed by BlocProvider or BlocProvider.builder
- Pass the bloc to other widgets tree without dispose management
See also BlocProvider.fromBlocContext
Example
BlocProvider<CounterBloc>.fromBloc(
bloc: BlocProvider<CounterBloc>.of(context),
child: AnotherPage(),
)
Implementation
BlocProvider.fromBloc({
Key? key,
required T bloc,
required Widget child,
}) : this(
key: key,
creator: (_context, _bag) => bloc,
child: child,
autoDispose: false,
);