错误状态:DocumentSnapshotPlatform 中不存在字段

时间:2021-02-13 09:50:43

标签: firebase flutter mobile google-cloud-firestore firebase-authentication

我尝试了这段代码,但它显示了这个错误:状态不佳:DocumentSnapshotPlatform 中不存在字段

body: Center(
        child: Container(
            padding: const EdgeInsets.all(20.0),
            child: StreamBuilder<QuerySnapshot>(
              stream: FirebaseFirestore.instance
                  .collection("users")
                  .doc(widget.uid)
                  .collection('tasks')
                  .snapshots(),
              builder: (BuildContext context,
                  AsyncSnapshot<QuerySnapshot> snapshot) {
                if (snapshot.hasError)
                  return new Text('Error: ${snapshot.error}');
                switch (snapshot.connectionState) {
                  case ConnectionState.waiting:
                    return new Text('Loading...');
                  default:
                    return new ListView(
                      children: snapshot.data.**docs**
                          .map<Widget>((DocumentSnapshot document) {
                        return new CustomCard(
                          title: document.data()['title'],
                          description: document.data()['description'],
                        );
                      }).toList(),
                    );
                }
              },
            )),
      ),strong text
<块引用>

请帮忙

1 个答案:

答案 0 :(得分:1)

此错误表明它无法在 cloud firestore 中找到该字段,从您发布的内容来看,您似乎正在尝试从 a.子集合,你需要确保文档 Id 是正确的,以及它的字段名称来拉它们。

相关问题