Milad-Akarie/form_field_validator

Check for null value is missing

npopok opened this issue · 0 comments

Looks like isValid methods are missing checks for null values.

For example, in RequiredValidator:

  @override
  bool isValid(String? value) {
    return value!.isNotEmpty;
  }

The issue leads to incompatibility with widgets like DropdownButtonFormField which may provide null values for validation and this code causes an exception.

It can be easily fixed by adding a null check for the method above:

  @override
  bool isValid(String? value) {
    return value != null && value.isNotEmpty;
  }