When I use the following line in my flutter code :
print(Directory("/sdcard").list(recursive: true).listen((event) {print(event);}));
I get the following error :
"[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FileSystemException: Directory listing failed, path = '/sdcard/' (OS Error: Permission denied, errno = 13)"
I tried adding these to AndroidManifest.xml under manifest tab :
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
But it didnt work. I also tried re-running it after flutter clean but still I got the same result.
Can someone please help me to fix this issue.
My main goal is to be able to access(read/write) all the accessible directories present in the storage of an android/ios device. Just like our regular phones File Manager.
Thanks a lot for answering.