imageCropper function
- BuildContext context,
- XFile image,
- double? aspectRatio
A utility function that allows the user to crop an image on mobile.
Implementation
Future<XFile?> imageCropper(
BuildContext context,
XFile image,
double? aspectRatio,
) async {
return ImageCropper().cropImage(
sourcePath: image.path,
aspectRatio: aspectRatio == null
? null
: CropAspectRatio(ratioX: aspectRatio, ratioY: 1),
uiSettings: [
AndroidUiSettings(),
IOSUiSettings(aspectRatioLockEnabled: true),
WebUiSettings(context: context, viewwMode: WebViewMode.mode_1),
],
).then(
(croppedFile) => croppedFile == null ? null : XFile(croppedFile.path),
);
}