I have Form and TextFormField inside it :
new Expanded(
child: TextFormField(
style: new TextStyle(color: Colors.white),
keyboardType: TextInputType.text,
validator: (String value) {
if (value.length <= 5) {
//Show error as a Snackbar
}
},
onSaved: (String value) {},
),
)
On a Buttom press I am checking if all the fields are validate :
if (_formKey.currentState.validate()) {
_submit();
}
Now the issue is when you call validate() and don't return any text in validate() method then it will consider it return true.
I don't want to show error below the textField but as a Snackbar.
Also, I tried setting an extra flag and setting in each validator Method but it gets complex if there are multiple fields in the form.
Can anyone tell me how can I handle this situation where _formKey.currentState.validate() should return false and validator method
inside TextFormField need not to return error text.