diff --git a/lib/logic/api_maps/rest_maps/server_providers/hetzner/hetzner_api.dart b/lib/logic/api_maps/rest_maps/server_providers/hetzner/hetzner_api.dart index f0f87bce..7dc1bd28 100644 --- a/lib/logic/api_maps/rest_maps/server_providers/hetzner/hetzner_api.dart +++ b/lib/logic/api_maps/rest_maps/server_providers/hetzner/hetzner_api.dart @@ -526,16 +526,15 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi { return GenericResult(data: servers, success: true); } - Future> getAvailableLocations() async { - List locations = []; + Future>> getAvailableLocations() async { + final List locations = []; final Dio client = await getClient(); try { - final Response response = await client.get( - '/locations', - ); - - locations = response.data!['locations']; + final Response response = await client.get('/locations'); + for (final location in response.data!['locations']) { + locations.add(HetznerLocation.fromJson(location)); + } } catch (e) { print(e); return GenericResult( diff --git a/lib/logic/models/json/hetzner_server_info.dart b/lib/logic/models/json/hetzner_server_info.dart index 96838b4e..0078a6ff 100644 --- a/lib/logic/models/json/hetzner_server_info.dart +++ b/lib/logic/models/json/hetzner_server_info.dart @@ -118,7 +118,14 @@ class HetznerPriceInfo { @JsonSerializable() class HetznerLocation { - HetznerLocation(this.country, this.city, this.description, this.zone); + HetznerLocation( + this.country, + this.city, + this.description, + this.zone, + this.name, + ); + final String name; final String country; final String city; final String description; diff --git a/lib/logic/providers/server_providers/hetzner.dart b/lib/logic/providers/server_providers/hetzner.dart index c74b83cc..e9fcccbf 100644 --- a/lib/logic/providers/server_providers/hetzner.dart +++ b/lib/logic/providers/server_providers/hetzner.dart @@ -116,15 +116,15 @@ class HetznerServerProvider extends ServerProvider { ); } - final List rawLocations = result.data; + final List rawLocations = result.data; for (final rawLocation in rawLocations) { ServerProviderLocation? location; try { location = ServerProviderLocation( - title: rawLocation['city'], - description: rawLocation['description'], - flag: getEmojiFlag(rawLocation['country']), - identifier: rawLocation['name'], + title: rawLocation.city, + description: rawLocation.description, + flag: getEmojiFlag(rawLocation.country), + identifier: rawLocation.name, ); } catch (e) { continue;