setAsyncValidators method

void setAsyncValidators(
  1. List<AsyncValidatorFunction> validators, {
  2. bool autoValidate = false,
  3. bool updateParent = true,
  4. bool emitEvent = true,
})

Sets the async validators that are active on this control. Calling this overwrites any existing async validators.

If autoValidate is true then the status of the control is recalculated after setting the new validators. If autoValidate is false (default) you must call updateValueAndValidity(), or assign a new value to the control for the new validation to take effect.

When updateParent is true or not supplied (the default) each change affects this control and its parent, otherwise only affects to this control. This argument is only taking into account if autoValidate is equals to true.

When emitEvent is true or not supplied (the default), both the statusChanges and valueChanges emit events with the latest status and value when the control is reset. When false, no events are emitted. This argument is only taking into account if autoValidate is equals to true.

Implementation

void setAsyncValidators(
  List<AsyncValidatorFunction> validators, {
  bool autoValidate = false,
  bool updateParent = true,
  bool emitEvent = true,
}) {
  clearAsyncValidators();
  _asyncValidators.addAll(validators);

  if (autoValidate) {
    updateValueAndValidity(updateParent: updateParent, emitEvent: emitEvent);
  }
}