I'm trying to delete documents from firestore
using:
FirebaseFirestore.instance
.collection("Data")
.where('user_id', isEqualTo: uid)
.get()
.then((snapshot) {
for (DocumentSnapshot ds in snapshot.docs) {
ds.reference.delete().then((value) {
print("document deleted");
moveToNextDeletion(); // <-The function shold be called only once
});
}
});
so once all documents deleted I wanna call moveToNextDeletion();
function, but it keeps calling until all documents deleted (cause of for loop).
Is there any way to call that function once all documents deleted?