galleryCrop function
Future<File?>
galleryCrop(
{ - required File imageFile,
- String toolbarTitle = 'Crop Image',
- Color toolbarColor = Colors.red,
- Color toolbarWidgetColor = Colors.white,
- Color backgroundColor = Colors.black,
- bool hideBottomControls = true,
- bool lockAspectRatio = false,
})
Implementation
Future<File?> galleryCrop({
required File imageFile,
String toolbarTitle = 'Crop Image',
Color toolbarColor = Colors.red,
Color toolbarWidgetColor = Colors.white,
Color backgroundColor = Colors.black,
bool hideBottomControls = true,
bool lockAspectRatio = false,
}) async {
CroppedFile? croppedImage = await ImageCropper().cropImage(
sourcePath: imageFile.path,
aspectRatioPresets: [
CropAspectRatioPreset.original,
CropAspectRatioPreset.square,
CropAspectRatioPreset.ratio3x2,
CropAspectRatioPreset.ratio4x3,
],
uiSettings: [
IOSUiSettings(
aspectRatioLockEnabled: false,
resetAspectRatioEnabled: false,
),
AndroidUiSettings(
toolbarTitle: toolbarTitle,
toolbarColor: toolbarColor,
toolbarWidgetColor: toolbarWidgetColor,
backgroundColor: backgroundColor,
hideBottomControls: hideBottomControls,
lockAspectRatio: lockAspectRatio,
),
],
);
File? file = File(croppedImage!.path);
return file;
}