fetchReverseGeo static method
Implementation
static Future<ReverseGeo> fetchReverseGeo(
{required String apiKey,
required String lat,
required String long}) async {
const String apiUrl = 'https://us1.locationiq.com/v1/reverse';
final String url = '$apiUrl?key=$apiKey&lat=$lat&lon=$long&format=json';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
final Map<String, dynamic> data = json.decode(response.body);
return ReverseGeo.fromJson(data);
} else {
throw Exception('Impossible de récupérer les infos');
}
}