cropImageNative method

  1. @override
Future<String?> cropImageNative({
  1. required String path,
  2. required double cropX,
  3. required double cropY,
  4. required double cropW,
  5. required double cropH,
  6. required double containerW,
  7. required double containerH,
  8. int rotation = 0,
  9. int quality = 85,
  10. String format = 'jpeg',
  11. int maxSize = 1200,
})
override

Crops an image natively without going through a Dart isolate.

Uses Android's BitmapFactory.inSampleSize / platform-native equivalents to decode only a fraction of the pixels, making resize ~50–150 ms instead of the ~10 s that pure-Dart decode takes on a 2+ MB JPEG.

path absolute path (or object URL on web) of the source image. cropX/cropY top-left of the crop rect in container coordinates. cropW/cropH size of the crop rect in container coordinates. containerW/containerH size of the Flutter widget that displayed the image. rotation clockwise degrees applied before cropping (0, 90, 180, 270). quality JPEG/WebP encode quality 0–100 (default 85, ignored for PNG). format output format: "jpeg" | "png" | "webp_lossy" | "webp_lossless". maxSize max edge length used when decoding the source (default 1200).

Returns the absolute path of the cropped file, or null on failure.

Implementation

@override
Future<String?> cropImageNative({
  required String path,
  required double cropX,
  required double cropY,
  required double cropW,
  required double cropH,
  required double containerW,
  required double containerH,
  int rotation = 0,
  int quality = 85,
  String format = 'jpeg',
  int maxSize = 1200,
}) async {
  throw UnsupportedError(
    'Web implementation is not supported on this platform',
  );
}