如何在 Flutter 中读取“_JsonQuerySnapshot”的实例列表
发布时间:2022-08-22 11:47:58 273
相关标签: # 数据库# 数据
我正在尝试从包含'_JsonQuerySnapshot' 实例数据的列表中读取数据。
在下面的代码中,我试图从数据库中获取数据
getData() async {
var db = FirebaseFirestore.instance;
var categoryList = [];
db.collection('categories')
.doc(value)
.get()
.then((DocumentSnapshot doc) {
var listSubCol = doc["categoryCollection"];
listSubCol.forEach((id) {
db.collection('categories')
.doc(value)
.collection(id)
.get()
.then((snapshot) {
categoryList.add(snapshot);
return categoryList;
});
});
});
}
下面是我正在打印值的代码。
FutureBuilder(
future: getData(),
builder: (BuildContext context, snapshot){
if (snapshot.hasError) {
return Text("Something went wrong");
}
if (snapshot.connectionState == ConnectionState.done) {
print('Data: ${snapshot.data}');
return Text("Text");
}
return Text("Text Outside");
}
)
我得到了空值。
谁能帮我获取数据吗。
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报