我有一个问题:将数据保存在Firebase中时,引号(“)总是自动出现在数字的前面和后面。问题是arduino不接受引号...如果创建新变量在Firebase中,这分配了一个固定的数字,没有引号,因此问题必须出在Flutter如何“上载”数字上。
在随附的图片上,您可以看到带引号的含义。 firebase - 在Firebase上保存时的引号-LMLPHP
为了理解代码:首先,我获得了新位置,然后变量latitudee获得了新位置所具有的纬度的值,然后变量latitudeRound成为了经度但变圆的变量。最后但并非最不重要的是,变量latitudeRound将被保存。

_location.onLocationChanged.listen((l) {
      print((l.latitude));
      setState(() {
        latitudee = l.latitude;
        latitudeRound = latitudee.toStringAsFixed(5);
      });
    });

FirebaseDatabase.instance
        .reference()
        .update({'latitudeBoot': latitudeRound});

最佳答案

我想这是因为您要发送到Firebase的数据类型。如果发送字符串,则得到“123”,但是如果发送int值,则得到123
在上传之前使用此解析字符串将其加倍

var doubleValue = double. parse(latitudeRound);
然后上传
[![FirebaseDatabase.instance
    .reference()
    .update({'latitudeBoot': doubleValue});

10-01 21:19