cropImage static method
Future<UFileData?>
cropImage({
- Uint8List? bytes,
- String? filePath,
- UCropOptions options = const UCropOptions(),
- dynamic action(
- UFileData file
Opens the cropper for bytes or a file path and returns the cropped image. await UFile.cropImage(bytes: data, options: const UCropOptions(shape: UCropShape.circle))
Implementation
static Future<UFileData?> cropImage({
Uint8List? bytes,
String? filePath,
UCropOptions options = const UCropOptions(),
Function(UFileData file)? action,
}) async {
Uint8List? data = bytes;
if (data == null && filePath != null && !kIsWeb) data = await File(filePath).readAsBytes();
if (data == null) return null;
final UFileData? cropped = await _openCropper(data, options);
if (cropped == null) return null;
action?.call(cropped);
return cropped;
}