BlocProvider<T extends Bloc> constructor
BlocProvider<T extends Bloc> ({
- Key? key,
- required BlocCreator<
T> creator, - Widget? child,
- 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,
);