flutter_image_cropper
flutter_image_cropper copied to clipboard
Unable to crop image square
Even after setting the aspectRatioPresets to Square. I can still crop in rectangle on Android. For iOS it's working fine.
class CropperImage { static Future<CroppedFile?> imageCropping(String sourcePath) async { CroppedFile? croppedFile = await ImageCropper().cropImage( compressQuality: 60, sourcePath: sourcePath, aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1), aspectRatioPresets: [ CropAspectRatioPreset.square, // CropAspectRatioPreset.ratio3x2, // CropAspectRatioPreset.original, // CropAspectRatioPreset.ratio4x3, // CropAspectRatioPreset.ratio16x9 ], uiSettings: [ AndroidUiSettings( toolbarTitle: 'Cropper', toolbarColor: ColorsConstant.primaryColor, toolbarWidgetColor: Colors.white, initAspectRatio: CropAspectRatioPreset.square, hideBottomControls: true, lockAspectRatio: false), IOSUiSettings( title: 'Cropper', aspectRatioLockEnabled: true, minimumAspectRatio: 1.0, aspectRatioLockDimensionSwapEnabled: false, aspectRatioPickerButtonHidden: true), ], ); return croppedFile; } }
@TAAkshay change lockAspectRatio
to true. It will then react based on CropAspectRatio
you defined.