hnvn / flutter_image_cropper

A Flutter plugin for Android and iOS supports cropping images
995 stars 391 forks source link

Unable to crop image square #369

Open TAAkshay opened 2 years ago

TAAkshay commented 2 years ago

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; } }

ZahraVe commented 2 years ago

@TAAkshay change lockAspectRatio to true. It will then react based on CropAspectRatio you defined.