updateError method

void updateError(
  1. String fieldName,
  2. String error
)

Updates the error message for the specified field and performs additional validation.

This method updates the error message for the specified field by appending it to any existing validation errors. It then updates the form's status to BondFormStateStatus.invalid.

  • fieldName The name of the field to update the error for.
  • error The new error message to append to any existing validation errors for the field.

Implementation

void updateError(String fieldName, String error) {
  final field = state.get(fieldName);
  final validationError = field.validate(state.fields);
  state.fields[fieldName] = field.updateError(
    validationError != null ? '$error\n$validationError' : error,
  );
  state = state.copyWith(
    fields: Map.from(state.fields),
    status: BondFormStateStatus.invalid,
  );
}