getUserPlaylists method

Future<List<Playlist>> getUserPlaylists(
  1. String url
)

Get the playlists of a user.

Note

  • UserId is not the same as the user's display name on Spotify. Obtain userId from Profile > Copy link to Profile on your spotify client.

  • The URL needn't be cleaned before passing it to this function.

Implementation

Future<List<Playlist>> getUserPlaylists(String url) async {
  var userPlaylists =
      await _spotifyEngine.playlists.getUsersPlaylists(SpotifyEngine.extractId(url)).all();

  return userPlaylists
      .map(
        (playlist) => Playlist(
          name: playlist.name!,
          user: playlist.owner!.displayName!,
          url: 'https://open.spotify.com/playlist/${playlist.id!}',
        ),
      )
      .toList();
}