[英]_TypeError (type 'Null' is not a subtype of type 'String') firebase firestore
I am trying to retrieve data from my cloud firestore but it keeps returning a type error.我正在尝试从我的云存储中检索数据,但它一直返回类型错误。 This is the code for firestore
这是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这是错误“_TypeError(类型'Null'不是'String'类型的子类型)”发生的地方
ListTile(
onTap: () {},
title: Text(
userMap["name"],
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(userMap["email"])
Text
widget doesnt accept null value, you can provide default value on null cases like Text
小部件不接受 null 值,您可以在 null 情况下提供默认值,例如
Text(userMap["name"]??"got NUll",)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.