getCroppedImage static method

Future<VPlatformFile?> getCroppedImage({
  1. bool isFromCamera = false,
})

Implementation

static Future<VPlatformFile?> getCroppedImage({
  bool isFromCamera = false,
}) async {
  final img = await getImage(isFromCamera: isFromCamera);
  if (img != null) {
    if (VPlatforms.isMobile) {
      final croppedFile = await ImageCropper().cropImage(
        sourcePath: img.fileLocalPath!,
        compressQuality: 70,
        cropStyle: CropStyle.circle,
        compressFormat: ImageCompressFormat.png,
        aspectRatioPresets: [
          CropAspectRatioPreset.square,
          CropAspectRatioPreset.ratio3x2,
          CropAspectRatioPreset.original,
          CropAspectRatioPreset.ratio4x3,
          CropAspectRatioPreset.ratio16x9
        ],
        uiSettings: [
          AndroidUiSettings(
            toolbarTitle: 'Crop It',
            toolbarColor: Colors.white,
            toolbarWidgetColor: Colors.black,
            initAspectRatio: CropAspectRatioPreset.original,
            lockAspectRatio: false,
          ),
          IOSUiSettings(
            title: 'Crop It',
          ),
        ],
      );

      if (croppedFile == null) {
        return null;
      }
      return VPlatformFile.fromPath(fileLocalPath: croppedFile.path);
    }
    return img;
  }
  return null;
}