【发布时间】: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