本文介绍了扑火,在数组中添加新对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有对象数组,我想在用户在数组中输入新数据时添加新对象吗?

I have array of objects, I want to add new object when user enter new data in the array?

Firestore.instance.collection(city).document('Attractions').updateData(
                        "data", FieldValue.arrayUnion(obj)
                      );

这显示了错误,我该如何通过颤振实现这一目标?

This shows error, How can I achieve this with flutter?

推荐答案

正确的格式是:

Firestore.instance.collection(city).document('Attractions').updateData({"data": FieldValue.arrayUnion(obj)});

updateDataMap<String,dynamic>作为数据.

在您的代码中,您正在使用,作为键-值之间的分隔符,而应该是:

In your Code you are having , as separator between key - value instead it should be :

这篇关于扑火,在数组中添加新对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 20:03
查看更多