【发布时间】:2021-06-07 12:35:21
【问题描述】:
我有一个问题,Firestore 中的一些文档具有相同的位置,并且在打印出正确的字符串时正确传递了位置,但我的 StreamBuilder 始终在 if 条件下执行 noData 函数。
Streambuilder 如下所示:
StreamBuilder(
stream: FilterFirebase().relatedLocationFilter(
eventDocument["location"], eventDocument["id"]),
builder: (BuildContext ctx,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData ||
snapshot.data.docs.isEmpty) {
return NoDataRelatedLocation();
} else {
return new RelatedLocationListing(
relatedLocationList: snapshot.data.docs,
);
}
},
)
我的 relatedLocationFilter 如下所示:
relatedLocationFilter(String location, String id) {
print(location);
print(id);
return FirebaseFirestore.instance
.collection("events")
.where("location", isEqualTo: location)
.where("id", isNotEqualTo: id)
.snapshots();
}
安全规则正常,没有 where 过滤器的代码工作正常。
更新:
日志:
颤振:Tj4EB68R1CwBYKPfWzcm
扑:米高梅宴会厅
颤动:1
Firestore 文档:
【问题讨论】:
标签: firebase flutter google-cloud-firestore where-clause stream-builder