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?


1 Answers

Community On Best Solutions

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