I am trying to achieve the best UX on Flutter using AutovalidateMode.onUserInteraction.
Option 1
When I set the validation on the form key, when a user tries to type one one texField the whole form goes red with errors.
child: Form(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
Option 2
When I set AutovalidateMode.onUserInteraction on each text field I end up getting the error on each textfield when the user tries to type and it disappears when they complete the input.
RoundedPasswordResetField(
validator: (value) {
if (value.isEmpty) {
return 'Please Re-enter Password';
}
if (password != confirmpassword) {
return "Password does not match";
}
//
return null;
},
autovalidateMode: AutovalidateMode.onUserInteraction,
hintText: "Please Re-enter Password",
onChanged: (value) {
confirmpassword = value;
},
),
Option 3
When I set it to autovalidateMode: AutovalidateMode.disabled,, when the user tries to submit the fields when they are empty, the errors appear, but when they key in the specific correct details the errors don't clear out
RoundedPasswordResetField(
validator: (value) {
if (value.isEmpty) {
return 'Please Re-enter Password';
}
if (password != confirmpassword) {
return "Password does not match";
}
//
return null;
},
autovalidateMode: AutovalidateMode.disabled,
hintText: "Please Re-enter Password",
onChanged: (value) {
confirmpassword = value;
},
),
How can I use setState, so that when the user starts typing the errors wont be shown immediately, and shown when they complete inputting wrong details - and achieve the best UX?