thumbnailDataWithSize method

Future<Uint8List?> thumbnailDataWithSize(
  1. ThumbnailSize size,
  2. {ThumbnailFormat format = ThumbnailFormat.jpeg,
  3. int quality = 100,
  4. PMProgressHandler? progressHandler,
  5. int frame = 0}
)

Obtain the thumbnail data with the given width and height of the asset.

Thumbnail data for videos are images, not compressed video.

See also:

Implementation

Future<typed_data.Uint8List?> thumbnailDataWithSize(
  ThumbnailSize size, {
  ThumbnailFormat format = ThumbnailFormat.jpeg,
  int quality = 100,
  PMProgressHandler? progressHandler,
  int frame = 0,
}) {
  assert(() {
    _checkThumbnailAssertion();
    return true;
  }());
  // Return null if the asset is audio or others.
  if (type == AssetType.audio || type == AssetType.other) {
    return Future<typed_data.Uint8List?>.value();
  }
  final ThumbnailOption option;
  if (Platform.isIOS || Platform.isMacOS) {
    option = ThumbnailOption.ios(
      size: size,
      format: format,
      quality: quality,
    );
  } else {
    option = ThumbnailOption(
      size: size,
      format: format,
      quality: quality,
      frame: frame,
    );
  }
  assert(() {
    option.checkAssertions();
    return true;
  }());

  return thumbnailDataWithOption(option, progressHandler: progressHandler);
}