首页 > 解决方案 > Flutter:如何从 Cloud Firestore 的数组数据字段中获取数据?

问题描述

我在 Firestore 中检索数据时遇到问题。我在我的字段中创建了数据,该数据是一个数组。现在我在检索它时遇到了问题。我在检索数据时使用 StreamBuilder。我怎样才能找回它?我的数据在“活动 - 随机 ID - 问题 { 我想要获取的数据数组}”中。请帮忙。

我的代码:

StreamBuilder<QuerySnapshot>(
                stream: db.collection('ACTIVITIES').snapshots(),
                builder: (context, snapshot) {
                  if (snapshot.hasData) {
                    return Column(
                        children: snapshot.data.documents
                            .map((doc) => buildItem(doc))
                            .toList());
                  } else {
                    return SizedBox();
                  }
                })

我的数据库结构:

链接到我的数据库图片

标签: flutterdartgoogle-cloud-firestore

解决方案


推荐阅读