-
Notifications
You must be signed in to change notification settings - Fork 464
Open
Description
My cropImage function is as below.
Future<void> _cropImage() async {
final croppedFile = await ImageCropper().cropImage(
//sourcePath: _pickedFile!.path,
sourcePath: widget.imageFile.path,
compressFormat: ImageCompressFormat.jpg,
compressQuality: 100,
uiSettings: [
AndroidUiSettings(
toolbarTitle: 'Cropper',
toolbarColor: Colors.deepOrange,
toolbarWidgetColor: Colors.white,
initAspectRatio: CropAspectRatioPreset.square,
lockAspectRatio: false,
aspectRatioPresets: [
CropAspectRatioPreset.original,
CropAspectRatioPreset.square,
CropAspectRatioPreset.ratio4x3,
],
),
],
);
if (croppedFile != null) {
File croppedFile_file = File(croppedFile.path);
File? file_webp = await _convertAndSaveWebP(croppedFile_file);
widget.onImageCropped(file_webp);
Navigator.pop(context, file_webp);
} else {
widget.onImageCropped(
null); // Handle if cropping was cancelled or failed
Navigator.pop(context, null);
}
}
I called inside initState() as below:
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_cropImage();
});
}
If I put a breakpoint at the line "if (croppedFile != null) {" that means when cropping is done and debugger is on. Just after 4-5 seconds app crashes.
Note: it gives me croppedFile but it crashes as well.
Why it is happening? Can anyone guide me resolve this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels