getFollowedArtists method

Future<List<User>> getFollowedArtists({
  1. int limit = 20,
  2. String? after,
})

Retrieves the list of artists followed by the current user.

Implementation

Future<List<User>> getFollowedArtists({int limit = 20, String? after}) async {
  final params = {
    'type': 'artist',
    'limit': limit.toString(),
    if (after != null) 'after': after,
  };

  final url = Uri.https(_baseApiHost, '/v1/me/following', params);

  final json = await _getJson(url);
  final artistsJson = json['artists'] as Map<String, dynamic>;
  final items = artistsJson['items'] as List<dynamic>;

  return items.map((item) => User.fromJson(item)).toList();
}