flutter_form_builder
flutter_form_builder copied to clipboard
Listen for all fields are valid without show errors
I want to disable/enable submit button when all fields are validated correctly. How can I archive it? I try using "onChanged" like this. It works, but I don't want all my fields to show errors for every changed
`FormBuilder( key: _formKey, onChanged: () { var newIsValid = _formKey.currentState?.validate() ?? false; if (newIsValid != isValid) { setState(() { isValid = newIsValid; }); } },
child: Column()`
i want to know too , how ?
Has a some solutions for this, every of them depends of state management. You can take a look in autovalidateMode
In my opinion that's should be the default behaviour. I.e. disabled button clearly indicates that the form is yet to complete, but fields' error boxes aren't screaming about fields that user hasn't time to fill.
Probably validation should be split into two parts – "validation state" and "showing validation errors". Then this behaviour could be just one more AutovalidateMode constant.
I think you can use _formKey.currentState?.isValid instead of validate() method