getDirectoryPath method

Future<String?> getDirectoryPath({
  1. String? dialogTitle,
  2. bool lockParentWindow = false,
  3. String? initialDirectory,
})

Selects a directory and returns its absolute path.

On Android, this requires to be running on SDK 21 or above, else won't work. Note: Some Android paths are protected, hence can't be accessed and will return / instead.

dialogTitle can be set to display a custom title on desktop platforms. Not supported on macOS. It will be ignored on other platforms.

If lockParentWindow is set, the child window (file picker window) will stay in front of the Flutter window until it is closed (like a modal window). This parameter works only on Windows desktop. On macOS the parent window will be locked and this parameter is ignored.

initialDirectory can be optionally set to an absolute path to specify where the dialog should open. Only supported on Linux, macOS, and Windows. On macOS the home directory shortcut (~/) is not necessary and passing it will be ignored. On macOS if the initialDirectory is invalid the user directory or previously valid directory will be used.

Returns a Future<String?> which resolves to the absolute path of the selected directory, if the user selected a directory. Returns null if the user aborted the dialog or if the folder path couldn't be resolved.

Note: on Windows, throws a WindowsException with a detailed error message, if the dialog could not be instantiated or the dialog result could not be interpreted. Note: Some Android paths are protected, hence can't be accessed and will return / instead. Note: The User Selected File Read entitlement is required on macOS.

Implementation

Future<String?> getDirectoryPath({
  String? dialogTitle,
  bool lockParentWindow = false,
  String? initialDirectory,
}) async =>
    throw UnimplementedError('getDirectoryPath() has not been implemented.');