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);
}
},
我没有收到任何错误或内容。 仍是一个跳板和方案规划,因此将非常赞赏: