setError method

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

Sets an error message for the specified field and updates the form state to invalid.

This method directly assigns the provided error message to the specified field and updates the form's status to BondFormStateStatus.invalid.

  • fieldName The name of the field to set the error for.
  • error The error message to set for the field.

Implementation

void setError(String fieldName, String error) {
  final field = state.get(fieldName);
  state.fields[fieldName] = field.updateError(error);
  state = state.copyWith(
    fields: Map.from(state.fields),
    status: BondFormStateStatus.invalid,
  );
}