[英]Read firebase doc and copy the data into dart list
How can I read the data of my Firebase document and put the data in a local list/array?如何读取 Firebase 文档的数据并将数据放入本地列表/数组中?
To get all data from Firestore.从 Firestore 获取所有数据。
FirebaseFirestore.instance
.collection("users")
.get()
.then((value) {
print(value.docs);
for (var element in value.docs) {
print(element.id);// you will get all ids here
}
});
If you want to upload one particular data from Firestore.如果你想从 Firestore 上传一个特定的数据。
FirebaseFirestore.instance
.collection("users")
.where("uid",
isEqualTo: 'your_uid')
.get()
.then((value) {
print(value.docs);
for (var element in value.docs) {
print(element.id); // single id of that collection
}
});
I have tried this once.... check if this is the same u looking for我已经尝试过一次....检查这是否与您正在寻找的相同
List<String> list=[];
final snapshot = await FirebaseFirestore.instance
.collection("users").get();
for(int x=0;x<snapshot.docs.length;x++)
{
list.add(snapshot.docs[x].id);
}
print(list);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.