查看 Flutter Web。似乎 Firestore Flutter Web 集成还不完善。 试图传递 {merge: true} 参数:
webFirestore
.collection("/users")
.doc(uid)
.set(map, {merge: true});
{merge: true} 带有红线下划线。尝试了不同的格式,都没有用。 有谁知道语法应该是什么样子?
这就是 firestore 文档所说的:
/// An object to configure the [WriteBatch.set] behavior.
/// Pass [: {merge: true} :] to only replace the values specified in
/// the data argument. Fields omitted will remain untouched.
@anonymous
@JS()
abstract class SetOptions {
/// Set to true to replace only the values from the new data.
/// Fields omitted will remain untouched.
external bool get merge;
external set merge(bool v);
external factory SetOptions({bool merge});
}
最佳答案
遇到了同样的问题,我相信这是可行的:
webFirestore
.collection("/users")
.doc(uid)
.set(map, SetOptions(merge: true));
关于flutter - SetOptions 在 Firestore Flutter WEB 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59344201/