DebouncedAsyncValidator class

Delays the execution of an AsyncValidator by a specified duration.

This validator is useful for scenarios where you want to delay validation until the user has stopped typing for a certain period. It helps to avoid excessive validation requests, for example, when validating a username for availability against a remote server.

The DebouncedAsyncValidator should be used when you need to specify a custom debounce time for a single validator. If you want to apply the same debounce time to all asynchronous validators of a form control, it is more convenient to use the FormControl.asyncValidatorsDebounceTime property.

Example:

final control = FormControl<String>(
  asyncValidators: [
    DebouncedAsyncValidator(
      Validators.delegateAsync((control) async {
        // Your validation logic here
        return null;
      }),
      500, // Debounce time in milliseconds
    ),
  ],
);

In this example, the validation will only be triggered after the user has stopped typing for 500 milliseconds.

Inheritance

Constructors

DebouncedAsyncValidator(AsyncValidator _validator, int _debounceTime)
Creates a new instance of the DebouncedAsyncValidator class.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(AbstractControl control) Future<Map<String, dynamic>?>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
validate(AbstractControl control) Future<Map<String, dynamic>?>
Validates the control.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited