getCurrentGame method

Future<GameStat?> getCurrentGame({
  1. String? summonerID,
  2. String? summonerName,
})

Implementation

Future<GameStat?> getCurrentGame({String? summonerID, String? summonerName}) async {
  var url =
      'https://$server.api.riotgames.com/lol/spectator/v4/active-games/by-summoner/$summonerID?api_key=$apiToken';
  var response = await http.get(
    Uri.parse(url),
  );
  if (response.statusCode != 404) {
    return GameStat.fromJson(
      json.decode(
        response.body,
      ),
      summonerName,
      summonerID,
    );
  }
  return null;
}