i am trying to get from the table Products, the specific products that the P_ID is added to cart now the code beneath work well but only retrieve one element
final Stream<QuerySnapshot> cart = FirebaseFirestore.instance
.collection('products')
.where('pid', isEqualTo: cartitems[0])
.snapshots();
however it doesn't work when I do it like this
Stream<QuerySnapshot>? cart;
for (var i = 0; i < cartitems.length; i++) {
cart = FirebaseFirestore.instance
.collection('products')
.where('pid', isEqualTo: cartitems[i])
.snapshots();
}
it gives me this error
The following StateError was thrown building StreamBuilder<QuerySnapshot<Object?>>(dirty, state: _StreamBuilderBaseState<QuerySnapshot<Object?>, AsyncSnapshot<QuerySnapshot<Object?>>>#9ea5d): Bad state: Snapshot has neither data nor error
The relevant error-causing widget was: StreamBuilder<QuerySnapshot<Object?>> StreamBuilder