i have to crop image when click double tap on image container that time image crop function call.
onDoubleTap: () {
_cropImage(context);
},
this image i have to direct to crop no new screen or not to use pick image direct this image i have to crop.
child: Image.asset(
'images/rose1.png',
width: width,
height: height,
fit: BoxFit.cover,
),
when this function call that time i have to show error of the sorce path not work.
Future<void> _cropImage(BuildContext context) async {
File? _croppedImage;
final croppedImage = await ImageCropper().cropImage(
sourcePath: 'images/rose1.png', // Replace with your image path
aspectRatioPresets: [
CropAspectRatioPreset.square,
CropAspectRatioPreset.ratio3x2,
CropAspectRatioPreset.original,
CropAspectRatioPreset.ratio4x3,
CropAspectRatioPreset.ratio16x9
],
uiSettings: [AndroidUiSettings(
toolbarTitle: 'Crop Image',
toolbarColor: Colors.deepOrange,
toolbarWidgetColor: Colors.white,
initAspectRatio: CropAspectRatioPreset.original,
lockAspectRatio: false,
),
],
);
if (croppedImage != null) {
File? file = File(croppedImage.path);
setState(() {
_croppedImage = file;
});
}
}
this error is show how to fix it.
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:image_cropper_platform_interface/src/method_channel/method_channel_image_cropper.dart': Failed assertion: line 72 pos 12: 'await File(sourcePath).exists()': is not true. E/flutter ( 9666): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61) E/flutter ( 9666): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5) E/flutter ( 9666): #2 MethodChannelImageCropper.cropImage (package:image_cropper_platform_interface/src/method_channel/method_channel_image_cropper.dart:72:12) E/flutter ( 9666): E/flutter ( 9666): #3 _MovableImageBoxState._cropImage (package:invitation_card_app/widgets/MovableImageBox.dart:434:26) E/flutter ( 9666):