【问题标题】:How to access document ID from firebase in flutter?如何在flutter中从firebase访问文档ID?
【发布时间】:2020-08-09 00:26:45
【问题描述】:

我正在使用颤振和 Firebase。 我有一个包含文档列表的集合,这些文档每个都有很多字段。 我有一个用于访问文档的 API,它返回每个文档中的详细信息列表。 但是,我想访问每个文档的文档 ID。该怎么做?

【问题讨论】:

    标签: json flutter networking


    【解决方案1】:

    如果您编写这样的查询,您可以获得文档的每个 documentId。

    _getDocuments() async {
    await _firestore.collection("yourCollection").getDocuments().
    then((myDocuments) {
      for (DocumentSnapshot eachDocument in myDocuments.documents) {
           print(eachDocument.documentID);
        } 
      }
    });
    

    }

    【讨论】:

    • 问题是我无法直接访问数据库。我必须使用 api 访问
    • 但是你最好澄清你到目前为止所做的事情,也许你甚至没有添加 firebase 包或谷歌服务 json 或者......应该更清楚
    • 嗨 Shivanshi,你发现你的问题了吗?
    猜你喜欢
    • 2020-11-02
    • 2023-01-12
    • 1970-01-01
    • 2020-12-19
    • 2021-07-05
    • 1970-01-01
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多