galleryCrop function

Future<File?> galleryCrop({
  1. required File imageFile,
  2. String toolbarTitle = 'Crop Image',
  3. Color toolbarColor = Colors.red,
  4. Color toolbarWidgetColor = Colors.white,
  5. Color backgroundColor = Colors.black,
  6. bool hideBottomControls = true,
  7. bool lockAspectRatio = false,
})

Implementation

Future<File?> galleryCrop({
  required File imageFile,
  String toolbarTitle = 'Crop Image',
  Color toolbarColor = Colors.red,
  Color toolbarWidgetColor = Colors.white,
  Color backgroundColor = Colors.black,
  bool hideBottomControls = true,
  bool lockAspectRatio = false,
}) async {
  CroppedFile? croppedImage = await ImageCropper().cropImage(
    sourcePath: imageFile.path,
    aspectRatioPresets: [
      CropAspectRatioPreset.original,
      CropAspectRatioPreset.square,
      CropAspectRatioPreset.ratio3x2,
      CropAspectRatioPreset.ratio4x3,
    ],
    uiSettings: [
      IOSUiSettings(
        aspectRatioLockEnabled: false,
        resetAspectRatioEnabled: false,
      ),
      AndroidUiSettings(
        toolbarTitle: toolbarTitle,
        toolbarColor: toolbarColor,
        toolbarWidgetColor: toolbarWidgetColor,
        backgroundColor: backgroundColor,
        hideBottomControls: hideBottomControls,
        lockAspectRatio: lockAspectRatio,
      ),
    ],
  );

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

  return file;
}