getThumbByteData method

Future<ByteData> getThumbByteData(
  1. int width,
  2. int height, {
  3. int quality = 100,

Requests a thumbnail for the Asset with give width and hegiht.

The method returns a Future with the ByteData for the thumb, as well as storing it in the _thumbData property which can be requested later again, without need to call this method again.

You can also pass the optional parameter quality to reduce the quality and the size of the returned image if needed. The value should be between 0 and 100. By default it set to 100 (max quality).

Once you don't need this thumb data it is a good practice to release it, by calling releaseThumb() method.


Future<ByteData> getThumbByteData(int width, int height,
    {int quality = 100}) async {
  if (width < 0) {
    throw new ArgumentError.value(width, 'width cannot be negative');

  if (height < 0) {
    throw new ArgumentError.value(height, 'height cannot be negative');

  if (quality < 0 || quality > 100) {
    throw new ArgumentError.value(
        quality, 'quality should be in range 0-100');

  Completer completer = new Completer<ByteData>();
      .setMessageHandler(_thumbChannel, (ByteData? message) async {
        .setMessageHandler(_thumbChannel, null);
    return message;

  await MultiImagePicker.requestThumbnail(
      _identifier, width, height, quality);
  return completer.future as FutureOr<ByteData>;