Flutter Firebase快照数据序列化

时间:2018-08-09 07:14:32

标签: firebase dictionary serialization dart flutter

我查询了Firebase数据库,并将返回的值保存到这样的Map中。

Map Entries = e.snapshot.value;

使用此功能打印返回的值:

  void iterateMapEntry(key, value) {
    print('Stored:$key:$value');
  }

Entries.forEach(iterateMapEntry);

打印为:

Stored:-LJO781Z-H7VPL_o8xUf:{location: [2.17721106256338, 2.486113049089908], secret: sp3zbw4k4dh2}

Stored:-LJItGo5CirPuh2zxvEv:{location: [2.17609942641248, 2.4911495670676227], secret: sp3zbtvvxfzb}

I tried to use List<double> loc = e.snapshot.value["location"]; to obtain the location into a double but it doesn't work.

例如,我如何序列化这些项目以将其放入类?并能够使用StoredItem.key,StoredItem.latitude,StoredItem.longitude,StoredItem.secret ...

访问它们

谢谢。

解决了使用将地图转换成列表的问题

List locations = Entries.values.toList();

0 个答案:

没有答案