Issue
The length of the string.
Returns the number of UTF-16 code units in this string. The number of [runes] might be fewer, if the string contains characters outside the Basic Multilingual Plane (plane 0):
TextFormField(
obscureText: true,
decoration: InputDecoration(
hintText: "Enter Password", labelText: "Password"),
validator: (value) {
if (value != null && value.isEmpty) {
return "Password cannot be empty";
} else if (value.length < 6) {
return "Password length should be atleast 6";
}
return null;
},
)
Solution
Restructure your if condition to :
if (value != null && value.isEmpty) {
if (value.length < 6) {
return "Password length should be atleast 6";
}
else {
return null ;
}
}
else {
return "Password cannot be empty";
}
Answered By - Sathya Prakash
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.