我查询了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();