thumbDataWithSize method

Future<Uint8List?> thumbDataWithSize(
  1. int width,
  2. int height, {
  3. ThumbFormat format = ThumbFormat.jpeg,
  4. int quality = 100,
  5. PMProgressHandler? progressHandler,
})

get thumb with size

Implementation

Future<Uint8List?> thumbDataWithSize(
  int width,
  int height, {
  ThumbFormat format = ThumbFormat.jpeg,
  int quality = 100,
  PMProgressHandler? progressHandler,
}) async {
  assert(width > 0 && height > 0, "The width and height must better 0.");
  assert(quality > 0 && quality <= 100, "The quality must between 0 and 100");

  /// Return null if asset is audio or other type, because they don't have such a thing.
  if (type == AssetType.audio || type == AssetType.other) {
    return null;
  }

  if (Platform.isIOS || Platform.isMacOS) {
    return thumbDataWithOption(
      ThumbOption.ios(
        width: width,
        height: height,
        format: format,
        quality: quality,
      ),
      progressHandler: progressHandler,
    );
  }

  return thumbDataWithOption(
    ThumbOption(
      width: width,
      height: height,
      format: format,
      quality: quality,
    ),
    progressHandler: progressHandler,
  );
}