BlocStateListener<T extends Bloc<BlocEvent, BlocState> > constructor
BlocStateListener<T extends Bloc<BlocEvent, BlocState> > ({
- required List<
BlocStateListenerBinder< stateBinders,BlocState> > - Widget? child,
- 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);
},
);