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

FlameBlocListener<B extends BlocBase<S>, S>({
  1. required void onNewState(
    1. S state
    ),
  2. void onInitialState(
    1. S state
    )?,
  3. B? bloc,
  4. bool listenWhen(
    1. S previousState,
    2. S newState
    )?,
  5. ComponentKey? key,
})

A Component which can listen to changes in a Bloc state.

Implementation

FlameBlocListener({
  required void Function(S state) onNewState,
  void Function(S state)? onInitialState,
  B? bloc,
  bool Function(S previousState, S newState)? listenWhen,
  super.key,
})  : _onNewState = onNewState,
      _onInitialState = onInitialState,
      _listenWhen = listenWhen {
  if (bloc != null) {
    this.bloc = bloc;
  }
}