Reputation: 13
How to delete item a particular item from 'Image' map in flutter. my structure is shown in the attached image.
Upvotes: 0
Views: 408
Reputation: 80904
Image
is an array, if you want to delete an item from the array, then do the following:
void deleteItem() async{
var firebaseUser = await FirebaseAuth.instance.currentUser();
Firestore.instance.collection("stories").document(firebaseUser.uid).updateData({
"images" : FieldValue.arrayRemove([imageURL])
}).then((_) {
print("success!");
});
}
Assuming the document id is the current userId
, then you can use arrayRemove
to remove an item from the array.
Upvotes: 2