image_crop
image_crop copied to clipboard
Throwing Error when tried to open the same image again.
When tried to open the same image again the next time, below mentioned errors are thrown.
by going through the error I get is null error is thrown.
But I am clicking on an image only when it is being displayed in the gallery pick view, then how come a null object is thrown.
and if I choose a new image which was never chosen earlier there is no error thrown.
I/Timeline( 4543): Timeline: Activity_launch_request time:798925952 intent:Intent { act=android.intent.action.GET_CONTENT typ=image/* }
E/flutter ( 4543): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(INVALID, Image source cannot be opened, null)
E/flutter ( 4543): #0 StandardMethodCodec.decodeEnvelope
E/flutter ( 4543): #1 MethodChannel.invokeMethod
E/flutter ( 4543): <asynchronous suspension>
E/flutter ( 4543): #2 ImageCrop.sampleImage
E/flutter ( 4543): <asynchronous suspension>
E/flutter ( 4543): #3 _ImageDemoPageState._openImage
E/flutter ( 4543): <asynchronous suspension>
E/flutter ( 4543): #4 _ImageDemoPageState._buildOpenImage.<anonymous closure>
E/flutter ( 4543): #5 _InkResponseState._handleTap
E/flutter ( 4543): #6 _InkResponseState.build.<anonymous closure>
E/flutter ( 4543): #7 GestureRecognizer.invokeCallback
E/flutter ( 4543): #8 TapGestureRecognizer._checkUp
E/flutter ( 4543): #9 TapGestureRecognizer.handlePrimaryPointer
E/flutter ( 4543): #10 PrimaryPointerGestureRecognizer.handleEvent
E/flutter ( 4543): #11 PointerRouter._dispatch
E/flutter ( 4543): #12 PointerRouter.route
E/flutter ( 4543): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent
E/flutter ( 4543): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent
E/flutter ( 4543): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent
E/flutter ( 4543): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue
E/flutter ( 4543): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket
E/flutter ( 4543): #18 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter ( 4543): #19 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter ( 4543): #20 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter ( 4543): #21 _invoke1 (dart:ui/hooks.dart:233:10)
E/flutter ( 4543): #22 _dispatchPointerDataPacket (dart:ui/hooks.dart:154:5)
E/flutter ( 4543):
Did you found some workaround to resolve this issue?
I am using image_cropper package now. seems author is inactive.
I have tried image_cropper. But it is not working for me. It throws error during build once edit AndroidManifest.xml. But this is a very clean plugin. I am trying to make this work.
issue may be with androidx switch your flutter project to androidX
Ah, I see.. I will check that.. 👍
This can happen if you are deleting sampled image from the cache. When cropping it still needs the original file to crop from.
I am not deleting sampled image. Actually I am using same example code from this repo.
Error is happening soon after we open a file. I mean same file on a second time. But If I choose a new file, it then works charm. Below image may help
I Apologize. Problem is something else. Actually some of the files that is shown in the gallery->recent tab are not physically present in the disk. In the recent tab it shows some thump nails, but actual picture might have got deleted from the phone. Code gets into this error when we select such image thump nails.
I realize that it is better to check the existence of image before we proceed. ie:
File image = await ImagePicker.pickImage(source: ImageSource.gallery);
if (FileSystemEntity.typeSync(image.path) !=
FileSystemEntityType.notFound) {
//Do other stuffs
}
else{
//Feedback to user "Photo cannot be read from gallery
}
But, is there any code in ImageCropPlugin.java file that deletes the actual image selected for cropping? sample.recycle(); ?
same issue here
Most Reliable Fix is to clear ImageCache just before calling Image Picking Dialog again:
if(imageCache != null) imageCache.clear();