字串的長度。
回傳此字串中 UTF-16 代碼單元的數量。如果字串包含基本多語言平面(平面 0)之外的字符,則 [runes] 的數量可能會更少:
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;
},
)
uj5u.com熱心網友回復:
將您的 if 條件重組為:
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";
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/449308.html
