Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views2 pages

@override

The document outlines a method for cropping an image using specified coordinates and various parameters such as source path, maximum dimensions, aspect ratio, and compression settings. It includes assertions to validate input parameters and constructs a map of arguments to be sent to a method for image cropping. The method returns a CropInfo object containing the cropped image's path and dimensions if successful.

Uploaded by

jaydeep.czed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

@override

The document outlines a method for cropping an image using specified coordinates and various parameters such as source path, maximum dimensions, aspect ratio, and compression settings. It includes assertions to validate input parameters and constructs a map of arguments to be sent to a method for image cropping. The method returns a CropInfo object containing the cropped image's path and dimensions if successful.

Uploaded by

jaydeep.czed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

@override

Future<CropInfo?> cropImageWithCoordinates({
required String sourcePath,
int? maxWidth,
int? maxHeight,
CropAspectRatio? aspectRatio,
ImageCompressFormat compressFormat = ImageCompressFormat.jpg,
int compressQuality = 90,
List<PlatformUiSettings>? uiSettings,
}) async {
assert(await File(sourcePath).exists());
assert(maxWidth == null || maxWidth > 0);
assert(maxHeight == null || maxHeight > 0);
assert(compressQuality >= 0 && compressQuality <= 100);

final arguments = <String, dynamic>{


'source_path': sourcePath,
'max_width': maxWidth,
'max_height': maxHeight,
'ratio_x': aspectRatio?.ratioX,
'ratio_y': aspectRatio?.ratioY,
'compress_format': compressFormat.name,
'compress_quality': compressQuality,
};

if (uiSettings != null) {
for (final settings in uiSettings) {
arguments.addAll(settings.toMap());
}
}

final String? resultPath =


await _channel.invokeMethod('cropImage', arguments);

if (resultPath == null) return null;

var splitResult = resultPath.split("|\\|");

return CropInfo(
path: splitResult[0],
x: double.parse(splitResult[1]),
y: double.parse(splitResult[2]),
width: double.parse(splitResult[3]),
height: double.parse(splitResult[4]),
);
}

You might also like