简体   繁体   English

_TypeError(类型'Null'不是类型'String'的子类型)firebase firestore

[英]_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.

相关问题 Flutter:_TypeError(类型“Null”不是“String”类型的子类型) - Flutter: _TypeError (type 'Null' is not a subtype of type 'String') 错误:_TypeError(类型“Null”不是类型“String”的子类型) - Error : _TypeError (type 'Null' is not a subtype of type 'String') flutter 中的 _TypeError(类型“Null”不是类型“String”的子类型) - _TypeError (type 'Null' is not a subtype of type 'String') in flutter _TypeError(类型“Null”不是“String”类型的子类型) - _TypeError (type 'Null' is not a subtype of type 'String') “Null”类型不是 flutter、firebase 中“字符串”的子类型 - type 'Null' is not a subtype of 'String' in flutter, firebase 输入“未来<null> ' 不是 flutter 和 Firebase 中类型转换中类型 'String' 的子类型</null> - type 'Future<Null>' is not a subtype of type 'String' in type cast in flutter and Firebase _TypeError(类型&#39;Null&#39;不是&#39;String&#39;类型的子类型)Flutter-jsonserialisable - _TypeError (type 'Null' is not a subtype of type 'String') Flutter-jsonserialisable _TypeError(类型 '(dynamic) => Null' 不是类型 '(String, dynamic) => void' 的 'f' 的子类型) - _TypeError (type '(dynamic) => Null' is not a subtype of type '(String, dynamic) => void' of 'f') _TypeError 在构建 NotesListView(dirty) 时被抛出:“Null”类型不是“String”类型的子类型 - _TypeError was thrown building NotesListView(dirty) : type 'Null' is not a subtype of type 'String' _TypeError(类型“Null”不是类型“String”的子类型)- 错误发生在 flutter - _TypeError (type 'Null' is not a subtype of type 'String') - error happening in flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM