setError method

void setError(
  1. int index,
  2. String? error
)

Sets the error message for an item.

Pass null or empty string to clear the error.

Implementation

void setError(int index, String? error) {
  if (index >= 0 && index < _errors.length) {
    _errors[index] = (error?.isEmpty ?? true) ? null : error;
  }
}