fetchForwardGeo static method
Implementation
static Future<List<ForwardGeo>> fetchForwardGeo(
{required String apiKey, required String query}) async {
const String apiUrl = 'https://us1.locationiq.com/v1/search';
final String url = '$apiUrl?key=$apiKey&q=$query&format=json';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
final List<dynamic> data = json.decode(response.body);
return data.map((e) => ForwardGeo.fromJson(e)).toList();
} else {
throw Exception('Impossible de récupérer les places');
}
}