setOverrideThumbnailFromMediaItem method

Future<void> setOverrideThumbnailFromMediaItem(
  1. {required AppModel appModel,
  2. required MediaItem item,
  3. required File? file,
  4. required bool clearOverrideImage}
)

Given a MediaItem, set its override display thumbnail. If null, this deletes the override thumbnail.

Implementation

Future<void> setOverrideThumbnailFromMediaItem({
  required AppModel appModel,
  required MediaItem item,
  required File? file,
  required bool clearOverrideImage,
}) async {
  String filename = getOverrideThumbnailFilename(
    appModel: appModel,
    item: item,
  );

  File thumbnailFile = File(filename);
  thumbnailFile.createSync(recursive: true);
  if (clearOverrideImage) {
    thumbnailFile.deleteSync();
  } else if (file != null) {
    file.copySync(filename);
  }
}