【问题标题】:Cloud Firestore not writing data consistently (Flutter)Cloud Firestore 写入数据不一致 (Flutter)
【发布时间】: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


    【解决方案1】:

    切换控制器和数据库逻辑

    【讨论】:

      猜你喜欢
      • 2018-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-28
      • 2021-03-03
      • 2021-11-26
      • 1970-01-01
      • 2020-01-18
      相关资源
      最近更新 更多