I have a form for user information and if one of the fields are empty I want to disable the submit button but my setState
is not updating the flags.
Here is my validateFields
function which is being called inside a build
method. Regex is 100% correct (I checked it multiple times)
void validateFields() {
RegExp regExp = new RegExp(r'[!@#<>?"\s:_`~;[\]\\|=+)(*&^%-]|^$');
if (regExp.hasMatch(nameController.text) || regExp.hasMatch(surnameController.text) || regExp.hasMatch(phoneController.text)){
setState(() {
isButtonDisabled = true;
});
}
else {
setState(() {
isButtonDisabled = false;
});
}
}
And Here is my submit button
onPressed: isButtonDisabled ? null : (){
//upload the form
}