FlameBlocProvider<B extends BlocBase<S>, S> constructor

FlameBlocProvider<B extends BlocBase<S>, S>({
  1. required B create(),
  2. List<Component>? children,
  3. ComponentKey? key,
})

A Component that provides a Bloc to its children

Will provide the Bloc returned by the create function, when this constructor is used, the bloc will only live while this component is alive.

Implementation

FlameBlocProvider({
  required B Function() create,
  List<Component>? children,
  super.key,
})  : _bloc = create(),
      _created = true {
  _addChildren(children);
}