process method

  1. @override
Future<CropParameters> process({
  1. required BuildContext context,
  2. required CropController controller,
  3. required File inputFile,
  4. required int inputFullWidth,
  5. required int inputFullHeight,
  6. required File preCroppedFile,
  7. required Directory directory,
  8. required int sequenceNumber,
  9. required List<Offset> offsets,
})
override

Processes the crop operation.

Implementation

@override
Future<CropParameters> process({
  required BuildContext context,
  required CropController controller,
  required File inputFile,
  required int inputFullWidth,
  required int inputFullHeight,
  required File preCroppedFile,
  required Directory directory,
  required int sequenceNumber,
  required List<Offset> offsets,
}) async {
  // in this case, it's an existing picture, with crop parameters.
  // we let the server do everything: better performance, and no privacy
  // issue here (we're cropping from an allegedly already privacy compliant
  // picture).
  final Rect cropRect = _getServerCropRect(
    controller,
    inputFullWidth,
    inputFullHeight,
  );
  await BackgroundTaskCrop.addTask(
    barcode,
    productType: productType,
    language: language,
    imageField: imageField,
    imageId: imageId,
    croppedFile: preCroppedFile,
    rotation: controller.rotation.degrees,
    x1: cropRect.left.ceil(),
    y1: cropRect.top.ceil(),
    x2: cropRect.right.floor(),
    y2: cropRect.bottom.floor(),
    context: context,
  );
  if (context.mounted) {
    await refresh(context);
  }
  return CropParameters.withoutFullFile(
    preCroppedFile: preCroppedFile,
    rotation: controller.rotation.degrees,
    cropRect: getLocalCropRect(controller),
  );
}