【问题标题】:How to get all documents from a collection without using StreamBuilder?如何在不使用 StreamBuilder 的情况下从集合中获取所有文档?
【发布时间】:2020-02-24 12:48:20
【问题描述】:

我想在不使用流生成器的情况下从 firestore 集合中获取所有文档,否则我将有嵌套流,并且在最后一个流中我得到一个空值。初始数据并没有解决我的问题。

Now I make a stream builder for that collection, when a snapshot is chosen I jump on other widget and there I also make a stream builder and here is the problem.

我只想在场景的最后一个小部件中制作流构建器,因为只需要实时更新数据。

【问题讨论】:

    标签: flutter google-cloud-firestore document stream-builder


    【解决方案1】:

    您可以通过以下方法使用 FutureBuilder

    await Firestore.instance.collection("books").getDocuments()
    

    【讨论】:

      【解决方案2】:

      使用这个获取实时数据:

       Firestore.instance
          .collection('books').snapshots().listen((querySnapshot){
      
      });
      

      【讨论】:

        猜你喜欢
        • 2020-10-23
        • 2021-12-10
        • 1970-01-01
        • 2020-08-09
        • 1970-01-01
        • 2018-03-22
        • 2020-08-12
        • 2021-03-30
        • 1970-01-01
        相关资源
        最近更新 更多