validateGranularly method

Set<FormFieldState<Object?>> validateGranularly()

Validates every FormField that is a descendant of this Form, and returns a Set of FormFieldState of the invalid field(s) only, if any.

This method can be useful to highlight field(s) with errors.

The form will rebuild to report the results.

See also:

  • validate, which also validates descendant FormFields, and return true if there are no errors.

Implementation

Set<FormFieldState<Object?>> validateGranularly() {
  final Set<FormFieldState<Object?>> invalidFields = <FormFieldState<Object?>>{};
  _hasInteractedByUser = true;
  _forceRebuild();
  _validate(invalidFields);
  return invalidFields;
}