cropImage static method

Future<FileData?> cropImage({
  1. Uint8List? bytes,
  2. String? filePath,
  3. UCropOptions options = const UCropOptions(),
  4. dynamic action(
    1. FileData file
    )?,
})

Implementation

static Future<FileData?> cropImage({
  Uint8List? bytes,
  String? filePath,
  UCropOptions options = const UCropOptions(),
  Function(FileData file)? action,
}) async {
  Uint8List? data = bytes;
  if (data == null && filePath != null && !kIsWeb) data = await File(filePath).readAsBytes();
  if (data == null) return null;

  final FileData? cropped = await _openCropper(data, options);
  if (cropped == null) return null;
  action?.call(cropped);
  return cropped;
}