【问题标题】:Bad state: field does not exist within the DocumentSnapshotPlatform错误状态:DocumentSnapshotPlatform 中不存在字段
【发布时间】:2021-05-16 21:47:30
【问题描述】:

我尝试了这段代码,但它显示了这个错误:错误状态: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

请帮忙

【问题讨论】:

  • 不明白确切的错误

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-09-28
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 2021-08-24
    • 2021-10-27
    相关资源
    最近更新 更多