getExternalStorageDirectory function

Future<Directory?> getExternalStorageDirectory()

Path to a directory where the application may access top level storage.

Example implementation:

  • getExternalFilesDir(null) on Android.

Throws an UnsupportedError if this is not supported on the current platform (for example, on iOS where it is not possible to access outside the app's sandbox).

Implementation

Future<Directory?> getExternalStorageDirectory() async {
  final String? path = await _platform.getExternalStoragePath();
  if (path == null) {
    return null;
  }
  return Directory(path);
}