fetchStation static method

Future<Station> fetchStation(
  1. String apiKey, {
  2. required String stationCode,
})

Implementation

static Future<Station> fetchStation(
  String apiKey, {
  required String stationCode,
}) async {
  final String host = _buildSingleStationUrl(
    stationCode: stationCode,
  );

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

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

  if (responseArr.isEmpty) return Station.empty();

  return Station.fromJson(responseArr);
}