resolve method

Future<ImageProvider<Object>?> resolve(
  1. NowPlayingTrack track
)
override

Returns an ImageProvider for a given NowPlayingTrack

If an image cannot be resolved, or does not need to be for some reason (e.g. we're happy with the image that has already been found in the system metadata) resolve should return null

Implementation

Future<ImageProvider?> resolve(NowPlayingTrack track) async {
  if (track.hasImage) return null;
  if (NowPlaying.spotify.isUnconnected) return null;

  final album = await _findAlbumFor(track);
  if (album is AlbumSimple) {
    final url = album.images!.first.url!;
    print('Found image using Spotify image resolver: $url');
    return NetworkImage(url);
  }

  print('No image found by Spotify');
  return null;
}