Dart: convert Map to List of Objects
List<Weight> weightData = List();
weights.forEach((k,v) => weightData.add(Weight(k,v)));
Following on Richard Heap's comment above, I would:
List<Weight> weightData =
mapData.entries.map( (entry) => Weight(entry.key, entry.value)).toList();
Don't forget to call toList
, as Dart's map
returns a kind of Iterable.