Fetching document with required field value, but this doesn't work
await FirebaseFirestore.instance
.collection('orders')
.where("id", isEqualTo: orderList[index].id)
.get()
.then((snapshot) {
snapshot.docs.first.reference.update({"status": 'Rejected'});
print("yes");
});
But this works
await FirebaseFirestore.instance
.collection('orders')
.where("id", isEqualTo: orderList[index].id)
.get()
.then((snapshot) {
//snapshot.docs.first.reference.update({"status": 'Rejected'});
print("yes");
});
Error
E/flutter (10845): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Bad state: No element