BlocProvider<T extends Bloc>.fromBlocContext constructor
BlocProvider<T extends Bloc>.fromBlocContext ({
- Key? key,
- required BuildContext context,
- required Widget child,
Pass the context that contains bloc which is managed by other widget.
Passed blocContext's bloc won't disposed automatically, so it should be managed appropriately.
See also BlocProvider.fromBloc
Example
BlocProvider<CounterBloc>.fromBlocContext(
context: context, // context's widget tree should contains the bloc
child: AnotherPage(),
)
Implementation
BlocProvider.fromBlocContext({
Key? key,
required BuildContext context,
required Widget child,
}) : this.fromBloc(
key: key,
bloc: BlocProvider.of(context),
child: child,
);