cameraCrop function

Future<File?> cameraCrop(
  1. dynamic filePath, {
  2. CropAspectRatio? aspectRatio,
  3. String toolbarTitle = 'Crop Image',
  4. Color toolbarColor = Colors.red,
  5. Color toolbarWidgetColor = Colors.white,
  6. bool hideBottomControls = true,
  7. bool lockAspectRatio = false,
})

Implementation

Future<File?> cameraCrop(
  filePath, {
  CropAspectRatio? aspectRatio,
  String toolbarTitle = 'Crop Image',
  Color toolbarColor = Colors.red,
  Color toolbarWidgetColor = Colors.white,
  bool hideBottomControls = true,
  bool lockAspectRatio = false,
}) async {
  CroppedFile? croppedImage = await ImageCropper().cropImage(
    sourcePath: filePath,
    aspectRatio: aspectRatio,
    cropStyle: CropStyle.rectangle,
    compressFormat: ImageCompressFormat.png,
    compressQuality: 100,
    uiSettings: [
      IOSUiSettings(
        rotateClockwiseButtonHidden: true,
        rotateButtonsHidden: true,
        resetButtonHidden: true,
        aspectRatioPickerButtonHidden: true,
        aspectRatioLockDimensionSwapEnabled: true,
        aspectRatioLockEnabled: true,
      ),
      AndroidUiSettings(
        toolbarTitle: toolbarTitle,
        toolbarColor: toolbarColor,
        toolbarWidgetColor: toolbarWidgetColor,
        hideBottomControls: hideBottomControls,
        lockAspectRatio: lockAspectRatio,
      ),
    ],
  );

  File? file = File(croppedImage!.path);

  return file;
}