getResult static method

Future<Uint8List?> getResult({
  1. required Rect clipRect,
  2. required Uint8List image,
  3. int? outputQuality,
  4. Size? outputSize,
})

get crop result image, type is Uint8List

Implementation

static Future<Uint8List?> getResult({required Rect clipRect, required Uint8List image, int? outputQuality, Size? outputSize}) async {

  final Size memoryImageSize = await getImageSize(image);
  final editorOption = ImageEditorOption();

  editorOption.addOption(ClipOption(
    x: clipRect.left * memoryImageSize.width,
    y: clipRect.top * memoryImageSize.height,
    width: clipRect.width * memoryImageSize.width,
    height: clipRect.height * memoryImageSize.height
  ));

  if(outputSize != null) {
    editorOption.addOption(ScaleOption(outputSize.width.toInt(), outputSize.height.toInt()));
  }

  editorOption.outputFormat = OutputFormat.jpeg(outputQuality ?? ImageCropOutputFormatQuality.High);
  final result = await ImageEditor.editImage(image: image, imageEditorOption: editorOption);
  return result;
}