BlocProvider<T extends Bloc> constructor

BlocProvider<T extends Bloc>({
  1. Key? key,
  2. required BlocCreator<T> creator,
  3. Widget? child,
  4. bool autoDispose = true,
})

Constructor for simple usage.

The child parameter should be omitted if and only if the provider is passed to BlocProviderTree.

Example

BlocProvider<CounterBloc>(
  creator: (_context, _bag) => CounterBloc(),
  child: App(),
)

Implementation

BlocProvider({
  Key? key,
  required BlocCreator<T> creator,
  Widget? child,
  bool autoDispose = true,
}) : this.builder(
        key: key,
        creator: creator,
        builder: (_context, _bloc) => child!,
        autoDispose: autoDispose,
      );