Closed lucasjinreal closed 2 years ago
Unfortunately I haven’t done anything with Flutter yet and don’t know the answer. According to https://stackoverflow.com/questions/49987707/how-to-save-an-image-to-the-photo-gallery-using-flutter it looks like you might need to write a native extension to do it.
Same request here.
For now, in my Flutter APP, I have wrote the native code for Android channel to refresh Mediastore, so that the image file can be found in Album. But it is quite inconvenient to write native code on this. This is a common requirement.
I would like to improve it so that 'Intent.ACTION_MEDIA_SCANNER_SCAN_FILE' can be called in Flutter code easily. It is quite small code and it is not worth to create an individual plugin. So that I searched the current plugins library and would like to add the function there. Unfortunately, so far I did not find a proper plugin to add it.
I am not sure if it is ok to add the function here. Means, adding a method like,
Image.refresh(file.path);
And then in the plugin code(might be Java), to add like,
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri uri = Uri.fromFile(new File(<filePath>));
intent.setData(uri);
sendBroadcast(intent);
Where <filePath>
is the image file path and provided in Image.refresh(file.path);
.
Thought?
Thank you!
Max Ma
If you're asking if I can add the Java code to the Image package, I don't think I'll be able to do that. I haven't and don't have any plans to do any Flutter development any time soon, and won't be able to test, support, or maintain any native solutions. If you wanted to add it to the package, and can verify it will be isolated to Android platform and not affect any other platform, then I'll certainly consider the pull request to add it in.
@maxatcn @brendan-duncan There is a library can do this now from community. It can downloads image from url and save image to album
@maxatcn @brendan-duncan There is a library can do this now from community. It can downloads image from url and save image to album
@jinfagang Please provide the link and usage instructions with IOS and Android. thx!
@nanunh I think it is here https://github.com/ko2ic/image_downloader . Meanwhile if you tested it success, pls let me know, and I can close this issue. BTW, this packages seems has some problem on iOS, if you have an iOS devices or mac, you can test iOS too.
https://pub.dev/packages/image_gallery_saver this one works with this module. This package has successfully worked on both iPhone (real device) and Android (emulator) for me. let me know if this solves this issue for you. Example. (use this code inside an async future function): var x = encodeJpg(image1); // image1 is of type Image from this library specifically await ImageGallerySaver.save(x);
can u show me an example how youre saving the picture ?
Same request here.
For now, in my Flutter APP, I have wrote the native code for Android channel to refresh Mediastore, so that the image file can be found in Album. But it is quite inconvenient to write native code on this. This is a common requirement.
I would like to improve it so that 'Intent.ACTION_MEDIA_SCANNER_SCAN_FILE' can be called in Flutter code easily. It is quite small code and it is not worth to create an individual plugin. So that I searched the current plugins library and would like to add the function there. Unfortunately, so far I did not find a proper plugin to add it.
I am not sure if it is ok to add the function here. Means, adding a method like,
Image.refresh(file.path);
And then in the plugin code(might be Java), to add like,Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(new File(<filePath>)); intent.setData(uri); sendBroadcast(intent);
Where
<filePath>
is the image file path and provided inImage.refresh(file.path);
.Thought?
Thank you!
Max Ma
does it work now?
I know this not a issue about image, but I want save a image into local album in flutter but CAN NOT found any solution about this. Here is what I got for now:
The image write to a new file, but this not saved as album and can not find the iOS or Android system album app. Anyone can give a hint how to achieve this?