Use case
FormState.validate causes all field to be validated even though the field has never been touched. There are cases when I want to only check whether the current form is valid without triggering UI changes on all the field.
For example:
I have a Form with 15 FormField and a submit button. I want to enable/disable the submit button based on whether there's a field that is notValid.
so I added onChanged: _updateSubmitButton() and _updateSubmitButton() will use the value from formKey.currentState.validate() to determine whether to enable or disable the submit button.
This will cause changing field 1 to make all the 15 fields to be validated and maybe show error just in order for me to disable the submit button.
Proposal
Add an isValid() method to FormState that will check whether all the field is valid.
This will also require isValid() to be added to FormFieldState in order not to rely on FormFieldState.validate() which will cause the error text to appear.
Use case
FormState.validatecauses all field to be validated even though the field has never been touched. There are cases when I want to only check whether the current form is valid without triggering UI changes on all the field.For example:
I have a
Formwith 15FormFieldand a submit button. I want to enable/disable the submit button based on whether there's a field that is notValid.so I added
onChanged: _updateSubmitButton()and_updateSubmitButton()will use the value fromformKey.currentState.validate()to determine whether to enable or disable the submit button.This will cause changing field 1 to make all the 15 fields to be validated and maybe show error just in order for me to disable the submit button.
Proposal
Add an
isValid()method toFormStatethat will check whether all the field is valid.This will also require
isValid()to be added toFormFieldStatein order not to rely onFormFieldState.validate()which will cause the error text to appear.