getExternalStorageDirectories function

Future<List<Directory>?> getExternalStorageDirectories(
  1. {StorageDirectory? type}
)

Paths to directories where application specific data can be stored externally.

These paths typically reside on external storage like separate partitions or SD cards. Phones may have multiple storage directories available.

Example implementation:

  • Context.getExternalFilesDirs(type) on Android (or Context.getExternalFilesDir(type) on API levels below 19).

Throws an UnsupportedError if this is not supported on the current platform. This is unlikely to ever be supported on any platform other than Android.

Implementation

Future<List<Directory>?> getExternalStorageDirectories({
  /// Optional parameter. See [StorageDirectory] for more informations on
  /// how this type translates to Android storage directories.
  StorageDirectory? type,
}) async {
  final List<String>? paths =
      await _platform.getExternalStoragePaths(type: type);
  if (paths == null) {
    return null;
  }

  return paths.map((String path) => Directory(path)).toList();
}