gpt4 book ai didi

dart - 在 flutter 中获取 Firestore 文档的 documentID?

转载 作者:IT王子 更新时间:2023-10-29 07:09:45 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com