I want to implement something like facebook's image picker with scans the whole device for photos and lets you choose one or multiple.
How do I get all the photos in one device with flutter without knowing the actual directory?
thanks.
You can use Image Picker plugin for Flutter plugin for Flutter for picking images from the image library, and taking new pictures with the camera. For Android, this should work out of the box while for iOS a slight tweaking is required.
Also don't forget to add read / write permissions in your
android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Don't forget to grant Storage permissions to your app, manually or by this plugin simple_permissions
If you're looking to retrieve all image files at once without using Image Picker, you can use the package Flutter_File_Manager and alter the absolute_paths to retrieve only image files (*.jpg, *.png, *.bmp, *.tiff, *.gif)
Again, don't forget to add uses-permissions like above in your AndroidManifest.xml
Related
I have a Flutter application that uploads pictures with image Picker and keeps track of the file path until the user connects to the internet and synchronize it, however some iOS users found that the images picked by Image Picker are deleted (No such file or Directoty), does this usually happen and the cache might be removed by time?
As documentation of image_picker says:
Images and videos picked using the camera are saved to your application's
local cache, and should therefore be expected to only be around temporarily.
If you require your picked image to be stored permanently,
it is your responsibility to move it to a more permanent location.
I am creating a flutter app using webview_flutter plugin, everything is working fine. In the website, there is a form in which users can upload images(that asks to choose weather to use Camera or Album to choose image). When I tap on Camera the app crashes.
Are you using the latest version of webview_flutter? I did a flutter pub upgrade and added
<key>NSCameraUsageDescription</key>
<string>Add image to profile</string>
to ios/Runner/Info.plist.
Crashes happen because your app needs to request a permission from user to access camera or photos library (depending on what user picks). But in order to make such request you need to provide a message with description on why do you need this permission. Such description should be added into Info.plist file located in ios/Runner folder of the project.
For the case you described with picking image from camera or photos library you need to add the following 2 keys with descriptions:
<key>NSCameraUsageDescription</key>
<string>Your description on why app needs access to camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Your description on why app needs access to photos library</string>
Here is information about mentioned keys in the official docs:
https://developer.apple.com/documentation/bundleresources/information_property_list/nscamerausagedescription
https://developer.apple.com/documentation/bundleresources/information_property_list/nsphotolibraryusagedescription
One more case with webview when you would need to have NSPhotoLibraryUsageDescription or NSPhotoLibraryAddUsageDescription in project's Info.plist file is to avoid crashes when user tries to download image via Save to photos context menu item. Such context menu appears when user long presses on some image on a web page.
The difference between 2 keys above is in fact that NSPhotoLibraryAddUsageDescription allows your app to only write (download) images to photos library, not read them, so it is more preferable way if you only want to let image downloads.
Here is info about this key: https://developer.apple.com/documentation/bundleresources/information_property_list/nsphotolibraryaddusagedescription
I have found lots of answers regarding how to download and save online photos to the app's cache or temporary directory. However, I need to know how to copy an image from the device's local gallery to the app's cache.
The reason for this is a strange problem with iOS, where attempting to upload images to Firebase, using paths of images in the gallery, always fails in a physical device and always works in iOS simulator and Android (both physical and simulated). In the app I am building I also have the ability to take photos, which are saved to the app's directories by the camera app, and those uploads work fine. I need to try and first copy the images to my cache, to test if it will allow me to upload them to firebase successfully. I am using multi_image_picker to get the local paths of the selected images from the gallery, all I need is to know, once I have those paths, how to copy a single one of those files to my app's temp directory (I use path_provider to get the appropriate path to temp directory).
It probably isn't a permissions issue because I have both Camera and Photo Library permissions in my plist.info, I get prompted for access and I can access the gallery without a problem when using the multi picker.
I have tried looking at the camera plugin's files and figure out how it does it, but no luck, I get lost once the plugin calls native methods.
I appreciate any help.
I can not save video file to iOS(to be visible in Photos app).
I have tried some plugins but they only save IMAGE(not video) to Photos.
I have used:
image_picker_saver: 0.3.0
It works fine for saving images(iOS), and rotates image for 90 degrees on Android.
For recording, I'm using image_picker: ^0.6.0+10
Any ideas?
Thanks.
Edit:
In the meantime, we have developed a plugin which supports saving both images and videos to gallery(android)/photos(ios), from Camera or url.
https://pub.dev/packages/gallery_saver
it has methods saveImage and saveVideo that take path or url(String).
Aside from the mentioned gallery_saver gallery_saver. There is another existing package that would do the trick, image_gallery_saver. Check this blog for the complete guide on how to save files to your own Flutter App Folder in Internal Phone Storage on Android and to the Photos Library on iOS Device. See also the package file_saver, which is another pretty decent plugin for saving files with formats like PDF, MP3, MP4, etc.
I was developing an ios application for file backup. In that I need to list and enable user to pick up files from any folder and need to do email backup like media and image picker.
I am struckup here with a bottle neck. I can't triger populating the list of document and email list for the user to pick. I had tried many codes, but it is not working.
I was working with the simulator.
Could anyone share their insight?
Regards
You should be more precise : do you want to pick up any file from any application on your device or just in your application library folder ? You can't access others applications folders.
You can find more information about the file system here :
https://developer.apple.com/library/mac/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
iPhone do not have a file browser.
The only place that a iPhone app can take file is from photo album.
Every application keeps its files in its private place.