问题描述
我正在开发一个应用程序,并且试图将布尔值更新为true,所以我尝试了updateData()
,但这只是擦除了整个文档的字段,因此,如果有人知道更好的方法,请..
解决方法
您可以使用setData()函数代替add()方法。
void createRecord() async {
await databaseReference.collection("books")
.document("1")
.setData({
'title': 'Flutter','description': 'Dart'
},merge=true);// setData sets the data of a document,if it does not exists,then it creates a document with the specified name
}