flutter firestore,在数组中添加新对象 [英] flutter firestore, add new object in array

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

问题描述

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

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 作为数据.

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

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆