validate method

  1. @override
Future<bool> validate()
override

Check the value of the current state in each validator and if have an error, the error of the current state will be updated.

Update state with FieldBlocState.isDirty to true to show a error Not validate if field already validated and not has error

Implementation

@override
Future<bool> validate() {
  if (state.isValidating) {
    emit(state.copyWith(
      isDirty: true,
    ) as State);
  } else if (state.hasError) {
    _validate(shouldDirty: true);
  }
  return _isValid();
}