validate method

bool validate()

Triggers field validation using FormField.validator.

Updates widget.errorText, notifies listeners of state updates via setState, and returns whether the field is currently valid.

Implementation

bool validate() {
  final nextError = widget.validator?.call(widget.value);
  if (mounted) {
    setState(() {
      widget.errorText = nextError;
    });
  } else {
    widget.errorText = nextError;
  }
  return widget.errorText == null;
}