cameraCrop function
Future<File?>
cameraCrop(
- dynamic filePath, {
- CropAspectRatio? aspectRatio,
- String toolbarTitle = 'Crop Image',
- Color toolbarColor = Colors.red,
- Color toolbarWidgetColor = Colors.white,
- bool hideBottomControls = true,
- bool lockAspectRatio = false,
})
Implementation
Future<File?> cameraCrop(
filePath, {
CropAspectRatio? aspectRatio,
String toolbarTitle = 'Crop Image',
Color toolbarColor = Colors.red,
Color toolbarWidgetColor = Colors.white,
bool hideBottomControls = true,
bool lockAspectRatio = false,
}) async {
CroppedFile? croppedImage = await ImageCropper().cropImage(
sourcePath: filePath,
aspectRatio: aspectRatio,
cropStyle: CropStyle.rectangle,
compressFormat: ImageCompressFormat.png,
compressQuality: 100,
uiSettings: [
IOSUiSettings(
rotateClockwiseButtonHidden: true,
rotateButtonsHidden: true,
resetButtonHidden: true,
aspectRatioPickerButtonHidden: true,
aspectRatioLockDimensionSwapEnabled: true,
aspectRatioLockEnabled: true,
),
AndroidUiSettings(
toolbarTitle: toolbarTitle,
toolbarColor: toolbarColor,
toolbarWidgetColor: toolbarWidgetColor,
hideBottomControls: hideBottomControls,
lockAspectRatio: lockAspectRatio,
),
],
);
File? file = File(croppedImage!.path);
return file;
}