getUserPlaylists method

Future<List<Playlist>> getUserPlaylists({
  1. int offset = 0,
  2. int limit = 50,
})

Retrieves playlists of the current user.

offset and limit control pagination.

Implementation

Future<List<Playlist>> getUserPlaylists({
  int offset = 0,
  int limit = 50,
}) async {
  final url = Uri.https(
    _baseApiHost,
    '/v1/me/playlists',
    {
      'limit': limit.toString(),
      'offset': offset.toString(),
    },
  );

  final jsonResponse = await _getJson(url);
  final items = jsonResponse['items'] as List<dynamic>;
  return items.map((item) => Playlist.fromJson(item)).toList();
}