getPlaylist method

Future<PlaylistModel?> getPlaylist(
  1. String playlistId
)

Retrieves detailed information about a specific playlist.

  • playlistId: The Spotify ID of the playlist.

Returns a PlaylistModel object representing the playlist's data.

Implementation

Future<PlaylistModel?> getPlaylist(String playlistId) async {
  try {
    // Make an API request to get playlist details
    final response = await _dio.get(
      'https://api.spotify.com/v1/playlists/$playlistId',
    );
    return PlaylistModel.fromMap(response.data);
  } catch (e, t) {
    throw Exception('Error fetching playlist: $e, $t');
  }
}