TextFormField(
obscureText: true,
decoration: InputDecoration(
hintText: "Enter password",
labelText: "Password",
),
validator: (value) {
if (value.isEmpty) {
return "Password can't be empty";
}
null;
},
),
I am watching a tutorial of flutter and i know its too basic but seems like , I can't fix this error I tried to search it but there is no proper guide to fix can someone help me in fixing this when its working fine on tutorial but not for me , and i don't get it yet its showing The property 'isEmpty' can't be unconditionally accessed because the receiver can be 'null'. Try making the access conditional (using '?.') or adding a null check to the target ('!').
this error
This is because value
is of type String?
and can be null. In you case you have to check if value
is null
.
TextFormField(
obscureText: true,
decoration: InputDecoration(
hintText: "Enter password",
labelText: "Password",
),
validator: (String? value) {
if (value != null && value.isEmpty) {
return "Password can't be empty";
}
null;
},
),
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments