removeFieldBlocsWhere method
Removes all FieldBlocs that satisfy test
.
Implementation
void removeFieldBlocsWhere(bool Function(T element) test) {
final nextFieldBlocs = [...state.fieldBlocs];
final fieldBlocsRemoved = <T>[];
nextFieldBlocs.removeWhere((e) {
if (test(e)) {
fieldBlocsRemoved.add(e);
return true;
}
return false;
});
if (fieldBlocsRemoved.isEmpty) return;
emit(state.copyWith(
isValidating: MultiFieldBloc.areFieldBlocsValidating(nextFieldBlocs),
isValid: MultiFieldBloc.areFieldBlocsValid(nextFieldBlocs),
fieldBlocs: nextFieldBlocs,
));
FormBlocUtils.removeFormBloc(
fieldBlocs: fieldBlocsRemoved,
formBloc: state.formBloc,
);
}