更新地图字段-Flutter

时间:2020-06-05 11:56:43

标签: firebase flutter dart google-cloud-firestore

如何更新isVerified(布尔值)字段的数据。 个人信息是“地图”包含地址,然后是“已验证”。

enter image description here

2 个答案:

答案 0 :(得分:3)

要更新isVerified,您必须执行以下操作:

Firestore.instance.collection("collection Name").document("documentId").updateData({
    "Personal Info.address.isVerified": true,
  }).then((_) {
    print("success!");
  });

答案 1 :(得分:2)

由于您没有提供您的收藏或文件名称,所以我会组成一个

因此,假设每次单击按钮时,值应更改为true

CollectionReference humanCollection = Firestore.instance.collection("collection Name");
//This is the button
FlatButton(
onPressed: () => changeValue();
 child : Container(
   Text : 'Change Value'
)
),

//This is the function

changeValue(){

humanCollection
        .document(currentHuman.id)//put the document name here
        .updateData({
          'Personal Info.address.isVerified' : true,
         });
}