getAlbum method

Future<AlbumModel?> getAlbum(
  1. String albumId
)

Retrieves detailed information about a specific album.

  • albumId: The Spotify ID of the album.

Returns an AlbumModel object representing the album's data.

Implementation

Future<AlbumModel?> getAlbum(String albumId) async {
  try {
    // Make an API request to get album details
    final response =
        await _dio.get('https://api.spotify.com/v1/albums/$albumId');
    return AlbumModel.fromMap(response.data);
  } catch (e) {
    print('Error fetching album: $e');
    return null;
  }
}