【问题标题】:how to use query on streambuilder flutter firestore如何在streambuilder flutter firestore上使用查询
【发布时间】:2021-08-17 00:26:36
【问题描述】:

我正在使用流构建器,我希望数据同时“排序”和“位置”。 导致每次我同时使用这两个查询时我的列表都不会显示,但是当我只使用 1 个查询时列表会显示

这里是我的流生成器​​

StreamBuilder<QuerySnapshot>(
                          stream: FirebaseFirestore.instance.collection("clothes")
                              .where('clothesCloset',
                                  isEqualTo: closet.closetId)
                              .snapshots(),
                          builder: (BuildContext context,
                              AsyncSnapshot<QuerySnapshot> snapshot) {
                            if (snapshot.hasError) {
                              return Text("Failed to load data!");
                            }
                            switch (snapshot.connectionState) {
                              case ConnectionState.waiting:
                                return ActivityServices.loadings();
                              default:
                                return new GridView(
                                  gridDelegate:
                                      SliverGridDelegateWithFixedCrossAxisCount(
                                    crossAxisCount: 2, //two columns
                                    mainAxisSpacing: 0.1, //space the card
                                    childAspectRatio: 0.800,
                                  ),
                                  children: snapshot.data.docs
                                      .map((DocumentSnapshot doc) {
                                    Clothes clothes;
                                    clothes = new Clothes(
                                      doc.data()['clothesId'],
                                      doc.data()['clothesName'],
                                      doc.data()['clothesDesc'],
                                      doc.data()['clothesImage'],
                                      doc.data()['clothesCloset'],
                                      doc.data()['clothesAddBy'],
                                      doc.data()['clothesAge'],
                                      doc.data()['clothesTag'],
                                      doc.data()['clothesStatus'],
                                      doc.data()['clothesLaundry'],
                                      doc.data()['createdAt'],
                                      doc.data()['updatedAt'],
                                    );
                                    return CardClothesLemari(clothes: clothes);
                                  }).toList(),
                                );
                            }
                          },
                        )

【问题讨论】:

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


    【解决方案1】:

    运行程序时检查控制台输出。应该有一行要求您为复合查询创建索引。错误消息将包含执行相同操作的直接链接。

    【讨论】:

    猜你喜欢
    • 2020-03-12
    • 1970-01-01
    • 2020-10-01
    • 2019-06-14
    • 2018-08-02
    • 1970-01-01
    • 2020-05-28
    • 2020-06-07
    • 1970-01-01
    相关资源
    最近更新 更多