I am trying to retrieve data from my cloud firestore but it keeps returning a type error. This is the code for firestore
await firestore
.collection('users')
.where("email", isEqualTo: _search.text)
.get()
.then((value) {
if (value.docs.isNotEmpty) {
setState(() {
userMap = value.docs[0].data();
isLoading = false;
});
}
This is where the error "_TypeError (type 'Null' is not a subtype of type 'String')" occurs
ListTile(
onTap: () {},
title: Text(
userMap["name"],
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(userMap["email"])
CodePudding user response:
Text
widget doesnt accept null value, you can provide default value on null cases like
Text(userMap["name"]??"got NUll",)