我有一张 Map<String, String>
类型的 map 我正在尝试将其上传到 Firestore 以匹配可用作字段的 map 数据类型。见下图。
我尝试使用 map 类的 toString 方法并将其分配给一个字段,但它显示为长字符串而不是 map ,请参阅下面的代码片段
Firestore.instance.collection('/mycollection').add({
'mapData' : myMap.toString(), // myMap.toString() = {data: test, data2: name}
}).then((onValue) {
// do something
}).catchError((e) {
print(e);
});
上面的代码片段上传 myMap
的字符串值作为字符串并将其分配给 mapdata
。它不会将 map 格式的数据发送到Firestore
关于如何发送 Map<string, string>
类型的任何想法到 Firestore 映射 map
的类型Firestore 提供吗?也来自List
到 Firestore array
最佳答案
我认为这会起作用
Firestore.instance.collection('/mycollection').add({
'mapData' : myMap,
}).then((onValue) {
// do something
}).catchError((e) {
print(e);
});
关于firebase - 将映射或数组的数据类型上传到 Firestore 数据库以匹配 Firestore 映射和数组类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54001190/