Cloud Firestore没有一致地写入数据(Flutter)



我在Stateful小部件中有TextFormField,带有控制器和onPress,可以将数据保存为Cloud Firestore中的文档。粗略地说,当我填写表单字段并保存时,它会显示firestore字段中的数据。对于其他3,每个"type"都返回"null"。如何解决这个问题?

onPressed: () async {
//save data to firebase
await db.collection("Contacts").add(
{
'Name': widget.contact.name,
'PhoneNumber': widget.contact.phoneNumber,
'Location': widget.contact.location,
'Birthday': widget.contact.birthday,
'Notes': widget.contact.notes
},
);
widget.contact.name = oneController.text;
widget.contact.phoneNumber = int.parse(twoController.text);
widget.contact.location = threeController.text;
widget.contact.birthday = int.parse(sixController.text);
widget.contact.notes = sevenController.text;
Navigator.pushReplacementNamed(context, "/second");
})

围绕切换控制器和数据库逻辑

最新更新