removeFieldBlocAt method

void removeFieldBlocAt(
  1. int index
)

Removes the FieldBloc in the index.

Implementation

void removeFieldBlocAt(int index) {
  if (state.fieldBlocs.length > index) {
    final nextFieldBlocs = [...state.fieldBlocs];
    final fieldBlocRemoved = nextFieldBlocs.removeAt(index);

    emit(state.copyWith(
      isValidating: MultiFieldBloc.areFieldBlocsValidating(nextFieldBlocs),
      isValid: MultiFieldBloc.areFieldBlocsValid(nextFieldBlocs),
      fieldBlocs: nextFieldBlocs,
    ));

    FormBlocUtils.removeFormBloc(
      fieldBlocs: [fieldBlocRemoved],
      formBloc: state.formBloc,
    );
  }
}