getSyncError method

ValidationResult? getSyncError(
  1. FormKey key
)

Retrieves the synchronous validation result for a specific form field.

This method returns the current validation state for the specified form key, converting asynchronous validations to WaitingResult objects. This provides a synchronous interface for accessing validation states.

Parameters:

  • key (FormKey): The form key to get validation result for

Returns the synchronous validation result or null if valid.

Implementation

ValidationResult? getSyncError(FormKey key) {
  var entry = _validity[key];
  var result = entry?.result;
  if (result is Future<ValidationResult?>) {
    return WaitingResult.attached(state: entry!.state, key: key);
  }
  return result;
}