getStatus function Null safety

Future<MojangStatus> getStatus()

Returns the Mojang and Minecraft API and website status

Might throw a Exception if no data or invalid data was returned.

Implementation

Future<MojangStatus> getStatus() async {
  final response = await request(http.get, _statusApi, 'check');
  if (response.statusCode != 200) {
    throw Exception('Failed to get Mojang API status.');
  }
  try {
    final list = parseResponseList(response);
    return MojangStatus.fromJson(list);
  } on FormatException catch (_) {
    return MojangStatus.empty();
  }
}