I'm currently struggling to remove a map item from a list in firebase. E.g. I want to remove item "0" from the list (completely).
I add the single array items in another place via FieldValue.arrayUnion with the updateData Method. This works perfectly fine. In another place in my I then want to have the possibility to remove the item from a list. I load the data via StreamBuilder and display ListTiles via ListView.builder. Now there I tried to replace arrayUnion by arrayRemove, but it doesn't work and I can't figure out why. Here's my code:
onPressed: () async {
try {
await Firestore.instance
.collection('users')
.document(futSnap.data.uid)
.collection('trainings')
.document(widget.trainingID)
.updateData(
{
'trainingTitle': widget.trainingTitle,
'trainingID': widget.trainingID,
'trainingDate': widget.trainingDate,
'category': widget.trainingCategory,
'trainingExercises':
FieldValue.arrayRemove(
[
{
'title': trainingExercises[i]
['title'],
'description':
trainingExercises[i]
['description'],
'imageURL': trainingExercises[i]
['imageUrl'],
'repetitions':
trainingExercises[i]
['repetitions'],
},
],
)
},
);
} catch (e) {
print(e);
}
},
I don't receive any error or something.. Still a beginner to flutter and programming, so help would be highly appreciated :)
