Harshal Gandhi
Harshal Gandhi

Reputation: 13

how to delete particular item from firebase storage map?

Data Structure

How to delete item a particular item from 'Image' map in flutter. my structure is shown in the attached image.

Upvotes: 0

Views: 408

Answers (1)

Peter Haddad
Peter Haddad

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

Related Questions