getGameHistory method

Future<List<Game>?> getGameHistory({
  1. String? accountID,
  2. String? summonerName,
})

Get an Future instance of the Game class as a List of it. So use the

.then(onValue){
  onValue[x]  //where x is the game you want (0 most-recent)
}

method to get their champion name, level and if chest aquired.

Implementation

Future<List<Game>?> getGameHistory({String? accountID, String? summonerName}) async {
  var url =
      'https://$server.api.riotgames.com/lol/match/v4/matchlists/by-account/$accountID?api_key=$apiToken';
  var response = await http.get(
    Uri.parse(url),
  );
  final matchList = json.decode(response.body)['matches'];
  gameList = [];
  matchList.forEach(
    (game) {
      gameList!.add(
        Game.fromJson(json.decode(json.encode(game)), this.apiToken, summonerName, this.server),
      );
    },
  );
  return gameList;
}