-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add feature to crop the image without clearing all the image cache #6
Comments
Hey there! After trying various of different things, i finally got it working. (Note that i slightly changed some other things for my needs, so if you have the same problem, you have to adjust it to yourself) Here is how my _processImage function looks like now: Future _processImage(File img, EdgeDetectionResult edgeDetectionResult) async {
if (!mounted || img == null) {
return;
}
widget.image.copy(widget.image.path + '_img.jpg');
File croppedImage = File(widget.image.path + '_img.jpg');
bool result = await EdgeDetector().processImage(croppedImage.path, edgeDetectionResult);
if (result == false) {
return;
}
Navigator.pop(context, {'croppedImage': croppedImage});
} I guess i now understand why it didnt work when you cleared all the cache, but idk how to explain it. And i believe there might be a better sollution to achieve what i want, so it would be still nice to hear from the author of the package! |
Hey there. Sorry for not having reacted on the issue. I haven't forgotten! The general problem is that upon the native call (that cuts the image based on the set edges), the image on the file system is being overridden. The displaying widget, though, does not notice something has changed because it does not observe such changes. Clearing the cache causes the widget to re-evaluate it. My idea was to add an argument to the processing method, allowing for the caller to determine where the processed image should be put. The path to the processed image, I would have stored in another variable than the original image path. The displaying widget could then check for the existence of the variable and display the new image in response to it not being null. It's great that you also found a way that works for you :). If you don't mind, I will try my approach when I find the time. |
Hey! Already sended an email about that, but thought other users might have the same issue, so decided to open an issue about it.
In my app, there can be lots of cached network images, and clearing the all cache is really a big problem, since these images would be downloaded to cache, and once user uses the edge detector again, all cahce would have been cleared again, and so on.
So it would be pretty good to have an option to not delete the all cache. (Im referring to the example project you created)
In scand.dart file, inside _processImage function, when you delete the following part, it does not crop the image:
So, is it possible to still achieve same thing, without clearing all the image cache?
I would also love to hear how this works behind the scenes, i mean why not clearing the image cache breaks the program.
The text was updated successfully, but these errors were encountered: