compressWithFile static method
Compress file of path
to Uint8List
.
Implementation
static Future<typed_data.Uint8List?> compressWithFile(
String path, {
int minWidth = 1920,
int minHeight = 1080,
int inSampleSize = 1,
int quality = 95,
int rotate = 0,
bool autoCorrectionAngle = true,
CompressFormat format = CompressFormat.jpeg,
bool keepExif = false,
int numberOfRetries = 5,
}) async {
if (numberOfRetries <= 0) {
throw CompressError("numberOfRetries can't be null or less than 0");
}
if (!File(path).existsSync()) {
throw CompressError('Image file does not exist in $path.');
}
final support = await _validator.checkSupportPlatform(format);
if (!support) {
return null;
}
final result = await _channel.invokeMethod('compressWithFile', [
path,
minWidth,
minHeight,
quality,
rotate,
autoCorrectionAngle,
_convertTypeToInt(format),
keepExif,
inSampleSize,
numberOfRetries
]);
return result;
}