validateAsync method

  1. @override
Future<bool> validateAsync({
  1. bool debounce = false,
})
override

Asynchronously validates all child controls and evaluates array-level asyncValidators.

Implementation

@override
Future<bool> validateAsync({bool debounce = false}) async {
  _debounceTimer?.cancel();
  _debounceTimer = null;
  final seq = ++_asyncValidationSeq;

  if (debounce && asyncDebounce > Duration.zero && asyncValidators.isNotEmpty) {
    _arrayValidating.value = true;
    final completer = Completer<bool>();
    _debounceTimer = Timer(asyncDebounce, () async {
      if (seq != _asyncValidationSeq) {
        completer.complete(false);
        return;
      }
      final result = await _executeValidation(seq, debounce: debounce);
      if (!completer.isCompleted) completer.complete(result);
    });
    return completer.future;
  }

  return _executeValidation(seq, debounce: debounce);
}