Flutter 如何获取 Firestore 中文档生成的 documentID?
我知道我可以像这样访问文档的各个字段:
return Firestore().collection(postPath).data.documents.forEach((response) {
nodeList.add(Post(
// response.data().id - how do i get the UID (example: -LUoDIu4wlVksjbbfIWE)?
response['content'],
response['date'],
response['flair'],
response['location'],
response['username'],
));
});
但是我不确定调用获取文档的UID的方法。
最佳答案
您正在寻找 documentId 属性。
String id = response.documentID;
如果您的响应对象不存在 documentId 属性,请将 cloud_firestore 插件更新到较新的版本。
关于dart - 在 flutter 中获取 Firestore 文档的 documentID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53983045/