MediaInfo.fromMap constructor

MediaInfo.fromMap(
  1. Map map, {
  2. bool updateArt = true,
  3. MediaInfo? oldMedia,
})

Implementation

factory MediaInfo.fromMap(
  Map<dynamic, dynamic> map, {
  bool updateArt = true,
  MediaInfo? oldMedia,
}) {
  assert(
    updateArt || oldMedia != null,
    'oldMedia must not be null if updateArt is false',
  );

  return MediaInfo(
    title: map['title'] as String?,
    artist: map['artist'] as String?,
    album: map['album'] as String?,
    queueIndex: map['queueIndex'] as int?,
    packageName: map['packageName'] as String?,
    albumArt: updateArt ? map['albumArt'] as Uint8List? : oldMedia?.albumArt,
    isPlaying: map['isPlaying'] as bool? ?? false,
    state: PlaybackState.fromString(map['state'] as String?),
  );
}