【发布时间】:2021-01-29 20:45:06
【问题描述】:
如果存在某些子集合,我在从 Firestore 查询中返回 true/false 语句时遇到问题。
这是我的代码:
Future<bool> checkIfCollectionExist(
String collectionName, String productId) async {
await _db
.collection('products')
.doc(productId)
.collection(collectionName)
.limit(1)
.get()
.then((value) {
return value.docs.isNotEmpty;
});
}
结果我得到了Future<bool> 的实例,但我需要true/false 的答案。
我在这里做错了什么?
【问题讨论】:
标签: flutter google-cloud-firestore future