Implementation
Future<List<VehicleEstimation>> fetchVehicleEstimations(
String cityName, String stopCode) async {
final response = await http.get(
Uri.parse('$apiBaseUrl/$cityName/$apiVersion/stop/$stopCode/estimation'));
if (response.statusCode == 200) {
List<dynamic> json = jsonDecode(response.body);
List<VehicleEstimation> vehicleEstimations = [];
for (final vehicleEstimation in json) {
vehicleEstimations.add(VehicleEstimation.fromJson(vehicleEstimation));
}
return vehicleEstimations;
} else {
throw Exception('Failed to load stop arrivals estimations.');
}
}