Update the Map field - Flutter

痞子三分冷 提交于 2021-02-10 14:16:25

问题


How to update data of isVerified (Boolean) field. Personal Info is Map contains address and then isVerified.


回答1:


To update isVerified, you have to do the following:

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



回答2:


Since you did not provide your collection or document name I would just form one

So lets assume every time we click a button the value should be changed to 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,
         });
}


来源:https://stackoverflow.com/questions/62214831/update-the-map-field-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!