Firebase 如何在streambuilder Flatter firestore上使用查询

Firebase 如何在streambuilder Flatter firestore上使用查询,firebase,flutter,google-cloud-firestore,stream-builder,Firebase,Flutter,Google Cloud Firestore,Stream Builder,我正在使用streambuilder,我希望同时使用数据“order by”和“where”。 因为每次我同时使用两个查询时,我的列表不会显示,但是当我只使用一个查询时,列表会显示 这是我的streambuilder StreamBuilder<QuerySnapshot>( stream: FirebaseFirestore.instance.collection("clothes")

我正在使用streambuilder,我希望同时使用数据“order by”和“where”。 因为每次我同时使用两个查询时,我的列表不会显示,但是当我只使用一个查询时,列表会显示

这是我的streambuilder

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(),
                                );
                            }
                          },
                        )
StreamBuilder(
流:FirebaseFirestore.instance.collection(“衣服”)
.其中(‘衣柜’,
isEqualTo:壁橱,closetId)
.snapshots(),
生成器:(BuildContext上下文,
异步快照(快照){
if(snapshot.hasError){
返回文本(“加载数据失败!”);
}
交换机(快照.连接状态){
案例连接状态。正在等待:
返回ActivityServices.loadings();
违约:
返回新的GridView(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount:2,//两列
mainAxisSpacing:0.1,//将卡隔开
childAspectRatio:0.800,
),
子项:snapshot.data.docs
.map((文档快照文档){
衣服;
衣服=新衣服(
doc.data(),
doc.data()['clothesName'],
doc.data(),
doc.data(),
doc.data(),
doc.data(),
doc.data(),
doc.data()['clothesTag'],
doc.data(),
doc.data(),
doc.data()['createdAt'],
doc.data()['updatedAt'],
);
返回CardClothersLemari(衣服:衣服);
}).toList(),
);
}
},
)

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