Updates MacOS directory picker to applescript
This commit is contained in:
parent
0d8c62b4f7
commit
fa80ef6132
|
@ -1,3 +1,6 @@
|
||||||
|
## 1.13.3
|
||||||
|
Go: Updates MacOS directory picker to applescript (thank you @trister1997).
|
||||||
|
|
||||||
## 1.13.2
|
## 1.13.2
|
||||||
Android: fixes picking paths from Downloads directory on versions below Android Q.
|
Android: fixes picking paths from Downloads directory on versions below Android Q.
|
||||||
|
|
||||||
|
|
|
@ -75,9 +75,23 @@ func fileDialog(title string, filter string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func dirDialog(title string) (string, error) {
|
func dirDialog(title string) (string, error) {
|
||||||
dirPath, _, err := dlgs.File(title, `*.*`, true)
|
osascript, err := exec.LookPath("osascript")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "failed to open dialog picker")
|
return "", err
|
||||||
}
|
}
|
||||||
return dirPath, nil
|
|
||||||
|
output, err := exec.Command(osascript, "-e", `choose folder with prompt "`+title+`"`).Output()
|
||||||
|
if err != nil {
|
||||||
|
if exitError, ok := err.(*exec.ExitError); ok {
|
||||||
|
fmt.Printf("miguelpruivo/plugins_flutter_file_picker/go: folder dialog exited with code %d and output `%s`\n", exitError.ExitCode(), string(output))
|
||||||
|
return "", nil // user probably canceled or closed the selection window
|
||||||
|
}
|
||||||
|
return "", errors.Wrap(err, "failed to open folder dialog")
|
||||||
|
}
|
||||||
|
|
||||||
|
trimmedOutput := strings.TrimSpace(string(output))
|
||||||
|
|
||||||
|
pathParts := strings.Split(trimmedOutput, ":")
|
||||||
|
path := string(filepath.Separator) + filepath.Join(pathParts[1:]...)
|
||||||
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: file_picker
|
name: file_picker
|
||||||
description: A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support.
|
description: A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support.
|
||||||
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
|
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
|
||||||
version: 1.13.2
|
version: 1.13.3
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
|
|
@ -33,7 +33,7 @@ class MethodChannelFilePicker extends FilePickerPlatform {
|
||||||
@override
|
@override
|
||||||
Future<String> getDirectoryPath() async {
|
Future<String> getDirectoryPath() async {
|
||||||
try {
|
try {
|
||||||
return await _channel.invokeMethod('dir');
|
return await _channel.invokeMethod('dir', {});
|
||||||
} on PlatformException catch (ex) {
|
} on PlatformException catch (ex) {
|
||||||
if (ex.code == "unknown_path") {
|
if (ex.code == "unknown_path") {
|
||||||
print(
|
print(
|
||||||
|
|
Loading…
Reference in New Issue