pick static method

Future<Directory?> pick({
  1. bool allowFolderCreation = false,
  2. required BuildContext context,
  3. bool barrierDismissible = true,
  4. Color? backgroundColor,
  5. required Directory rootDirectory,
  6. String? message,
  7. ShapeBorder? shape,
})

Opens a dialog to allow user to pick a directory.

If message is non null then it is rendered when user denies to give external storage permission. A default message will be used if message is not specified. rootDirectory is the initial directory whose sub directories are shown for picking

If allowFolderCreation is true then user will be allowed to create new folders directly from the picker. Make sure that you add write permission to manifest if you want to support folder creationa

Implementation

static Future<Directory?> pick(
    {bool allowFolderCreation = false,
    required BuildContext context,
    bool barrierDismissible = true,
    Color? backgroundColor,
    required Directory rootDirectory,
    String? message,
    ShapeBorder? shape}) async {
  if (Platform.isAndroid) {
    Directory? directory = await showDialog<Directory>(
        context: context,
        barrierDismissible: barrierDismissible,
        builder: (BuildContext context) {
          return DirectoryPickerData(
              allowFolderCreation: allowFolderCreation,
              backgroundColor: backgroundColor,
              child: _DirectoryPickerDialog(),
              message: message,
              rootDirectory: rootDirectory,
              shape: shape);
        });

    return directory;
  } else {
    throw UnsupportedError('DirectoryPicker is only supported on android!');
  }
}