setFieldError method

void setFieldError(
  1. String id,
  2. String? error
)

Sets forced internal error for a form field Throws if the field with id is not registered with the form.

Implementation

void setFieldError(String id, String? error) {
  final field = _fields[id];
  if (field == null) {
    throw FlutterError(
      'Field with id "$id" not found. '
      'Make sure the field is registered with the form.',
    );
  }
  field.setError(error);
}