2

Say I have folders like movies, ifont, song, images, whatsapp, etc

On my External storage, I want to access files from any of the folders above and store to a list using flutter.

I already added the necessary permissions to android.xml But I am clueless on how to go further from there,
I would appreciate a code snippet.

Thanks.

SleekyJay
  • 43
  • 1
  • 7
  • 1
    https://flutter.io/assets-and-images/ Please try to make it more clear what you try to accomplish. What do you want to do with the files in the folders? Where do the files come from? What is the problem? – Günter Zöchbauer Jun 28 '18 at 12:19
  • I want to display images from the specific folder on an image view. – SleekyJay Jun 28 '18 at 12:23
  • Then the link in my previous comment should provide the answers you are looking for. – Günter Zöchbauer Jun 28 '18 at 12:24
  • Sorry, but I wasn't talking about assets. I meant files on my Android device, think of it like a gallery app, displaying images on an Android phone.. – SleekyJay Jun 28 '18 at 12:25
  • My aim is to read this images to a list and display them in my app. I.e from the user's phone – SleekyJay Jun 28 '18 at 12:26
  • You can do that, but you need to list them in Dart code manually. Like `const List images = {'image1': 'assets/images/image1.png', 'image2': 'assets/images/image2.png', 'image3': 'assets/images/image3.png', };` and then you can use `AssetBundle` to load the entries. There is ongoing work to get this code auto-generated for assets. – Günter Zöchbauer Jun 28 '18 at 12:29
  • You haven't understood my question yet sir, i want to get images from the user's phone. For example images gotten from camera, or images downloaded to the user's phone or already on SDcard. I am not talking about assets. I don't know if I am clear enough now – SleekyJay Jun 28 '18 at 12:49
  • You can check image_picker or similar plugins. They are still a bit limited though. You might build your own plugin until better out-of-the-box solutions become available. – Günter Zöchbauer Jun 28 '18 at 12:50

1 Answers1

2

you can use listSync to get the list of sub-directories and files and you will get a list of FileSystemEntity.you also need to get persmmison to external storage so use this plugin

Raouf Rahiche
  • 28,948
  • 10
  • 85
  • 77