BlocProvider<T extends BaseBloc> constructor

BlocProvider<T extends BaseBloc>({
  1. Key? key,
  2. required T initBloc(
    1. BuildContext
    ),
  3. Widget? child,
})

Create a BlocProvider that provides a bloc to all descendants. The bloc created on first access, by calling initBloc.

BaseBloc.dispose will be called when BlocProvider is removed from the tree permanently (State.dispose called).

Implementation

BlocProvider({
  Key? key,
  required T Function(BuildContext) initBloc,
  Widget? child,
})  : _provider = Provider<T>.factory(
        initBloc,
        key: key,
        disposer: (bloc) => bloc.dispose(),
        child: child,
      ),
      super(key: key);