diff --git a/lib/api.dart b/lib/api.dart index a00664b..3afc6ba 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -71,9 +71,10 @@ class API { return ret; } - Future> getLocations() async { - var resp = jsonDecode(await getRequest("$instance/locations")); - return resp as List; + Future> getLocations() async { + var resp = jsonDecode(await getRequest("$instance/locations")) + as Map; + return resp.map((key, value) => MapEntry(key, Location(value))); } Future getItem(String item) async { diff --git a/lib/pages/supply.dart b/lib/pages/supply.dart index ff4dab5..49705ee 100644 --- a/lib/pages/supply.dart +++ b/lib/pages/supply.dart @@ -194,9 +194,10 @@ class _SupplyPageState extends State { } Future>> _fetchData() async { - var locations = await API().getLocations(); + var locations_map = await API().getLocations(); var origins = await API().getUniqueField(widget.item.id, variant, "origin"); origins.insert(0, ""); + var locations = locations_map.keys.toList(); locations.insert(0, ""); return {'locations': locations, 'origins': origins}; }