compress static method

Future<Uint8List?> compress(
  1. dynamic data
)

compress can used in compute function PASS DATA AS LIST First parameter always the input of Uint8List Second parameter is size in bytes (MaxSizeInBytes)int If anyone value is missing then compress will emit null

Implementation

static Future<Uint8List?> compress(dynamic data) async {
  Uint8List? inputUin8List;
  int? maxSizeInBytes;
  if (data is List) {
    inputUin8List = data[0];
    maxSizeInBytes = data[1];
  }

  if (inputUin8List == null || inputUin8List.isEmpty || maxSizeInBytes == null || (maxSizeInBytes) == 0) {
    return null;
  }
  final inputImage = img.decodeImage(inputUin8List);
  if (inputImage != null) {
    final compressedImageBytes = ImageCompressor()._compressImage(inputImage, maxSizeInBytes);
    return compressedImageBytes;
  } else {
    return null;
  }
}