【问题标题】:Get Database from firestore and using within RefreshIndicator in Flutter从 Firestore 获取数据库并在 Flutter 的 RefreshIndicator 中使用
【发布时间】:2021-06-14 06:37:34
【问题描述】:

大家好,我正在从 firestore 获取数据。在这种情况下,我试图将 RefreshIndicator() 添加到 onRefresh();当我只使用没有查询的数据时,我看不到任何错误,它的工作原理很清楚

tumGonderiler() async {
QuerySnapshot myQuerySnapshot = await akisRef.get();
setState(() {
  this.tEdilenGonderiler = myQuerySnapshot.docs.map((e) => e.data()).toList();
});

} 但是当我尝试使用 where 参数在我的集合中查询时,onRefresh() 在我的页面中不起作用,不起作用的代码如下

tumGonderiler() async {
QuerySnapshot myQuerySnapshot = await akisRef.where("ownerID", whereIn: takipEdilenKullanicilar.map((e) => e.id).toList()).get();
setState(() {
  this.tEdilenGonderiler = myQuerySnapshot.docs.map((e) => e.data()).toList();
});

}

【问题讨论】:

    标签: flutter google-cloud-firestore


    【解决方案1】:

    我已经稍微更改了我的代码,直到现在它正在工作,你可以从下面关注

    tumGonderiler() async {
    QuerySnapshot snapshot1 = await takipEdilenRef.doc(anlikKullanici!.id).collection("takipEdilenler").get();
    List<tEdilen> kullaniciress = snapshot1.docs.map((doc) => tEdilen.fromDocument(doc)).toList();
    setState(() {
      this.takipEdilenKullanicilar = kullaniciress;
    });
    QuerySnapshot myQuerySnapshot = await akisRef.where("ownerID", whereIn: takipEdilenKullanicilar.map((e) => e.id).toList()).get();
    List<Gonderiler> kullanicires = myQuerySnapshot.docs.map((e) => Gonderiler.fromDocument(e)).toList();
    setState(() {
      this.tEdilenGonderiler = kullanicires;
    });
    }
    
    
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: baslik(context, strBaslik: "Kartlar", geriButonuYokSay: true),
      body: RefreshIndicator(
          color: Colors.black,
          child: ListView(
            children: tEdilenGonderiler,
          ),
          onRefresh: () {
            return tumGonderiler();
          }),
    );
    

    【讨论】:

      猜你喜欢
      • 2020-10-01
      • 2018-12-20
      • 1970-01-01
      • 2021-04-17
      • 1970-01-01
      • 2020-12-17
      • 2020-10-25
      • 1970-01-01
      • 2020-09-12
      相关资源
      最近更新 更多