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;
},
)
CodePudding user response:
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";
}