Car*_*ein 1 dart flutter google-cloud-firestore
如何在 Flutter 中的 Firestore 中获取文档的生成文档 ID?
我知道我可以像这样访问文档的各个字段:
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'],
));
});
Run Code Online (Sandbox Code Playgroud)
但我不确定调用获取文档 UID 的方法。
您正在寻找 documentId 属性。
String id = response.documentID;
Run Code Online (Sandbox Code Playgroud)
如果您的响应对象不存在 documentId 属性,请将 cloud_firestore 插件更新为更新版本。
| 归档时间: |
|
| 查看次数: |
3482 次 |
| 最近记录: |