cropImage method
Implementation
@override
Future<XFile> cropImage({
required XFile pickedFile,
required BuildContext context,
}) async {
try {
final CroppedFile? croppedFile = await ImageCropper().cropImage(
sourcePath: pickedFile.path,
uiSettings: [
AndroidUiSettings(
toolbarTitle: 'Cropper',
toolbarColor: Colors.deepOrange,
toolbarWidgetColor: Colors.white,
aspectRatioPresets: [
CropAspectRatioPreset.original,
CropAspectRatioPreset.square,
CropAspectRatioPresetCustom(),
],
),
IOSUiSettings(
title: 'Cropper',
aspectRatioPresets: [
CropAspectRatioPreset.original,
CropAspectRatioPreset.square,
CropAspectRatioPresetCustom(),
],
),
WebUiSettings(context: context),
],
);
return croppedFile != null ? XFile(croppedFile.path) : pickedFile;
} catch (e) {
debugPrint('AppImageCropperService | error: $e');
return pickedFile;
}
}