【发布时间】:2020-03-19 21:23:30
【问题描述】:
我想更新一个文档字段,我尝试了以下代码,但它没有更新。
谁能给我一个解决方案,好吗?
我的代码:
var snapshots = _firestore
.collection('profile')
.document(currentUserID)
.collection('posts')
.snapshots();
await snapshots.forEach((snapshot) async {
List<DocumentSnapshot> documents = snapshot.documents;
for (var document in documents) {
await document.data.update(
'writer',
(name) {
name = this.name;
return name;
},
);
print(document.data['writer']);
//it prints the updated data here but when i look to firebase database
//nothing updates !
}
});
【问题讨论】:
-
试试
document.setData(Map);而不是document.data.update
标签: firebase flutter dart google-cloud-firestore