fetchNextBuses static method

Future<NextBuses> fetchNextBuses(
  1. String apiKey, {
  2. required String stopId,
})

Implementation

static Future<NextBuses> fetchNextBuses(
  String apiKey, {
  required String stopId,
}) async {
  final String host = _buildUrl(
    stopId: stopId,
  );

  final response = await http.get(
    Uri.parse(host),
    headers: {"api_key": apiKey},
  );

  Map<String, dynamic> responseArr = readJson(response.body);

  if (responseArr.isEmpty) return const NextBuses.empty();

  return NextBuses.fromJson(responseArr);
}