BlocProvider<T extends Bloc>.builder constructor

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

Constructor for advanced usage.

Example

BlocProvider<CounterBloc>.builder(
  creator: (context, bag) {
    // Do some work with `context` and `bag`.
    // ...
    return CounterBloc();
  },
  builder: (context, bloc) {
    // Do some work with `context` and `bloc`.
    // ...
    return App();
  },
)

Implementation

const BlocProvider.builder({
  Key? key,
  required this.creator,
  required this.builder,
  this.autoDispose = true,
}) : super(key: key);