我正在使用provider
和Stream
从Firestore提取数据。所以现在我想访问内部集合。但我无法获取数据。我如何访问myOrders集合。
这就是消防站的结构。
我尝试获取此代码,但对我不起作用。
//Store data into myOrders collection
Future myOrders(String image, String price) async {
final FirebaseUser user = await _auth.currentUser();
return await userData
.document(user.uid)
.collection('myOrders')
.document()
.setData({
'orderedImage': image,
'orderedPrice': price,
});
}
// get the data as snapshot
List<OrderedModel> myOrderSnapShot(QuerySnapshot snapshot) {
return snapshot.documents.map((doc) {
return OrderedModel(
orderedImage: doc.data['orderedImage'] ?? '',
orderedPrice: doc.data['orderedPrice']);
}).toList();
}
// get the snapshot as stream
Stream<List<OrderedModel>> get orderedStream {
return userData.document(uid).collection('myOrders').snapshots().map(myOrderSnapShot);
}```
答案 0 :(得分:1)
您尝试打印这些值并调试代码吗?