Reputation: 79
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):
Upvotes: 0
Views: 202
Reputation: 1
Encountering the same issue running my app on my physical Android device.
Same steps as above, was working fine with Flutter 3.10.0.
First noticed it after upgrading to Flutter 3.10.1.
Running flutter clean
and flutter pub
get fixed it for me as well
Upvotes: 0
Reputation: 102
Whenever there is an issue related to the method channel while installing a new package, you should consider to clean your pub cache from your system as the package might be having some conflicts with the other cached packages in your system. So just run
flutter pub cache clean
flutter pub get
And voila! You won't have issues running your package anymore.
Upvotes: 0