【发布时间】:2021-01-22 17:29:17
【问题描述】:
我在 Stateful 小部件中有 TextFormField,带有控制器和 onPress,可将数据保存为 Cloud Firestore 中的文档。当我填写表单字段并保存时,大约有四分之一的时间会显示 Firestore 字段中的数据。对于其他 3 个,每个“类型”都返回“空”。如何解决这个问题?
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");
})
【问题讨论】:
标签: flutter google-cloud-firestore