简体   繁体   中英

Better path_provider

just wondering if there is any way to access files on the system. not just the directories provider by path_provider?

seems like this should be part of core flutter, or at least a package. maybe most flutter apps don't require files from elsewhere (or maybe most apps in general, I'm just starting out)

I want to scan the file system for audio files. I know I could do it in android, as I made a little demo app to try some things with native code

The issue is that each platform is very much different, both in what you're able to do and how files are arranged.

The path_provider does actually have a way of getting the external files directory: getExternalStorageDirectory . However, that only works on Android as iOS doesn't allow reading files outside the app's sandbox. But once you use that you can use dart:io's File and Directory classes to read the files.

You also need permission on android to be able to read files. Putting this in your manifest should do it, but there's tons of android-specific answers that will tell you more.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Note that on iOS, there are ways to access specific types of files (ie pictures and videos), just no normal filesystem access.

Also note that if you've already done in android native code, you can use platform channels to interface between flutter and the native code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM