topTracks method

Future<Iterable<Track>> topTracks(
  1. String artistId,
  2. Market country
)

Returns the top tracks of an artist with its artistId inside a country

Implementation

Future<Iterable<Track>> topTracks(String artistId, Market country) async {
  var query = _buildQuery({
    'country': country.name,
  });
  var jsonString = await _api._get('$_path/$artistId/top-tracks?$query');
  var map = json.decode(jsonString);

  var topTracks = map['tracks'] as Iterable<dynamic>;
  return topTracks.map((m) => Track.fromJson(m));
}