searchable_dropdown icon indicating copy to clipboard operation
searchable_dropdown copied to clipboard

Validator Not Working Properly

Open Zujaj opened this issue 4 years ago • 1 comments

I wrapped the SearchableDropdown.single inside a Form Widget which has a global key. I defined the SearchableDropdown's validator as (value)=> value == null ? 'field required' : null . On button pressed

onPressed: () {
               if (_myFormKey.currentState.validate()) {
                   // Show success message
                 }
               else {
                    // Show error                   
                }

The validator does not respond correctly and allows me to show success message on null values. Please look into this matter asap!

Zujaj avatar Oct 28 '20 10:10 Zujaj

I wrapped the SearchableDropdown.single inside a Form Widget which has a global key. I defined the SearchableDropdown's validator as (value)=> value == null ? 'field required' : null . On button pressed

onPressed: () {
               if (_myFormKey.currentState.validate()) {
                   // Show success message
                 }
               else {
                    // Show error                   
                }

The validator does not respond correctly and allows me to show success message on null values. Please look into this matter asap!

hi, i'm try to this, maybe can be solved your problem `String selectValidation;

validator: (value) => this.selectValidation,

validation: () { if (selectValidation== null) { setState(() { this.selectValidation= 'Skema is required'; }); } else { setState(() { this.skemaValidation = null; }); }

      if (!_formKey.currentState.validate()) {
        return "Fill form correctly";
      }
      return null;
    },`

ariefyudia avatar Nov 18 '20 04:11 ariefyudia