BlocStateListener<T extends Bloc<BlocEvent, BlocState>> constructor

BlocStateListener<T extends Bloc<BlocEvent, BlocState>>({
  1. required List<BlocStateListenerBinder<BlocState>> stateBinders,
  2. Widget? child,
  3. T? bloc,
})

Implementation

BlocStateListener({required List<BlocStateListenerBinder> stateBinders, Widget? child, T? bloc})
    : super(
        child: child,
        bloc: bloc,
        listenWhen: (previous, state) => stateBinders.where((element) => element.isActive(state)).isNotEmpty,
        listener: (context, state) {
          var activeBinders = stateBinders.where((element) => element.isActive(state));
          if (activeBinders.isEmpty) return;
          activeBinders.first.listener(context, state);
        },
      );