Addresses an issue with plugin calls on Go (Desktop) (#241)
This commit is contained in:
parent
e39aa10134
commit
c13124f9bb
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,10 +1,14 @@
|
||||||
## 1.6.2
|
## 1.6.3+1
|
||||||
|
Addresses an issue with plugin calls on Go (Desktop) - Linux & Windows
|
||||||
|
|
||||||
* Updates GO (Desktop) to support multiple extension filters.
|
## 1.6.3
|
||||||
|
Addresses an issue with plugin calls on Go (Desktop) - MacOS
|
||||||
|
|
||||||
|
## 1.6.2
|
||||||
|
Updates Go (Desktop) to support multiple extension filters.
|
||||||
|
|
||||||
## 1.6.1
|
## 1.6.1
|
||||||
|
Addresses an issue that could result in permission handler resolving requests from other activities.
|
||||||
* Addresses an issue that could result in permission handler resolving requests from other activities.
|
|
||||||
|
|
||||||
## 1.6.0
|
## 1.6.0
|
||||||
|
|
||||||
|
@ -18,12 +22,10 @@
|
||||||
* Adds check that ensures that you one uses `FileType.custom` when providing a custom file extension filter;
|
* Adds check that ensures that you one uses `FileType.custom` when providing a custom file extension filter;
|
||||||
|
|
||||||
## 1.5.0+2
|
## 1.5.0+2
|
||||||
|
Updates channel name on iOS.
|
||||||
* Updates channel name on iOS.
|
|
||||||
|
|
||||||
## 1.5.0+1
|
## 1.5.0+1
|
||||||
|
Adds temporary workaround for (#49365)(https://github.com/flutter/flutter/issues/49365) until 1.14.6 lands on stable channel.
|
||||||
* Adds temporary workaround for (#49365)(https://github.com/flutter/flutter/issues/49365) until 1.14.6 lands on stable channel.
|
|
||||||
|
|
||||||
## 1.5.0
|
## 1.5.0
|
||||||
|
|
||||||
|
@ -31,11 +33,9 @@
|
||||||
* Added support for new [Android plugins APIs](https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration) (Android V2 embedding);
|
* Added support for new [Android plugins APIs](https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration) (Android V2 embedding);
|
||||||
|
|
||||||
## 1.4.3+2
|
## 1.4.3+2
|
||||||
|
|
||||||
Updates dependencies.
|
Updates dependencies.
|
||||||
|
|
||||||
## 1.4.3+1
|
## 1.4.3+1
|
||||||
|
|
||||||
Removes checked flutter_export_environment.sh from example app.
|
Removes checked flutter_export_environment.sh from example app.
|
||||||
|
|
||||||
## 1.4.3
|
## 1.4.3
|
||||||
|
@ -44,7 +44,6 @@ Removes checked flutter_export_environment.sh from example app.
|
||||||
* Fixes an issue that could result in a crash when tapping multiple times in the same media file while picking, on some iOS devices (#171).
|
* Fixes an issue that could result in a crash when tapping multiple times in the same media file while picking, on some iOS devices (#171).
|
||||||
|
|
||||||
## 1.4.2+1
|
## 1.4.2+1
|
||||||
|
|
||||||
Updates go-flutter dependencies.
|
Updates go-flutter dependencies.
|
||||||
|
|
||||||
## 1.4.2
|
## 1.4.2
|
||||||
|
|
|
@ -9,24 +9,36 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fileFilter(method string, extensions []string, size int) (string, error) {
|
func fileFilter(method string, extensions []string, size int, multi bool) (string, error) {
|
||||||
switch method {
|
switch method {
|
||||||
case "any":
|
case "ANY":
|
||||||
|
if multi {
|
||||||
|
return "*", nil
|
||||||
|
}
|
||||||
return `"public.item"`, nil
|
return `"public.item"`, nil
|
||||||
case "image":
|
case "IMAGE":
|
||||||
|
if multi {
|
||||||
|
return "jpg, jpeg, bmp, gif, png", nil
|
||||||
|
}
|
||||||
return `"public.image"`, nil
|
return `"public.image"`, nil
|
||||||
case "audio":
|
case "AUDIO":
|
||||||
|
if multi {
|
||||||
|
return "mp3, wav, midi, ogg, aac", nil
|
||||||
|
}
|
||||||
return `"public.audio"`, nil
|
return `"public.audio"`, nil
|
||||||
case "video":
|
case "VIDEO":
|
||||||
|
if multi {
|
||||||
|
return "webm, mpeg, mkv, mp4, avi, mov, flv", nil
|
||||||
|
}
|
||||||
return `"public.movie"`, nil
|
return `"public.movie"`, nil
|
||||||
case "custom":
|
case "CUSTOM":
|
||||||
var i int
|
var i int
|
||||||
var filters = ""
|
var filters = ""
|
||||||
for i = 0 ; i<size ; i++ {
|
for i = 0; i < size; i++ {
|
||||||
filters += `"` + extensions[i] + `"`
|
filters += extensions[i]
|
||||||
if i < size - 1 {
|
if i < size-1 {
|
||||||
filters += `,`
|
filters += ", "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return filters, nil
|
return filters, nil
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,27 +1,25 @@
|
||||||
package file_picker
|
package file_picker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gen2brain/dlgs"
|
"github.com/gen2brain/dlgs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fileFilter(method string, extensions []string, size int) (string, error) {
|
func fileFilter(method string, extensions []string, size int, isMulti bool) (string, error) {
|
||||||
switch method {
|
switch method {
|
||||||
case "any":
|
case "ANY":
|
||||||
return `*.*`, nil
|
return `*.*`, nil
|
||||||
case "image":
|
case "IMAGE":
|
||||||
return `*.png *.jpg *.jpeg`, nil
|
return `*.png *.jpg *.jpeg`, nil
|
||||||
case "audio":
|
case "AUDIO":
|
||||||
return `*.mp3`, nil
|
return `*.mp3 *.wav *.midi *.ogg *.aac`, nil
|
||||||
case "video":
|
case "VIDEO":
|
||||||
return `*.webm *.mpeg *.mkv *.mp4 *.avi *.mov *.flv`, nil
|
return `*.webm *.mpeg *.mkv *.mp4 *.avi *.mov *.flv`, nil
|
||||||
case "custom":
|
case "CUSTOM":
|
||||||
var i int
|
var i int
|
||||||
var filters = ""
|
var filters = ""
|
||||||
for i = 0 ; i<size ; i++ {
|
for i = 0; i < size; i++ {
|
||||||
filters += `*.` + extensions[i] + ` `
|
filters += `*.` + extensions[i] + ` `
|
||||||
}
|
}
|
||||||
return filters, nil
|
return filters, nil
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -7,17 +7,17 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fileFilter(method string) (string, error) {
|
func fileFilter(method string, extensions []string, size int, isMulti bool) (string, error) {
|
||||||
switch method {
|
switch method {
|
||||||
case "any":
|
case "ANY":
|
||||||
return "*", nil
|
return "*", nil
|
||||||
case "image":
|
case "IMAGE":
|
||||||
return "Images (*.jpeg,*.png,*.gif)\x00*.jpg;*.jpeg;*.png;*.gif\x00All Files (*.*)\x00*.*\x00\x00", nil
|
return "Images (*.jpeg,*.png,*.gif)\x00*.jpg;*.jpeg;*.png;*.gif\x00All Files (*.*)\x00*.*\x00\x00", nil
|
||||||
case "audio":
|
case "AUDIO":
|
||||||
return "Audios (*.mp3)\x00*.mp3\x00All Files (*.*)\x00*.*\x00\x00", nil
|
return "Audios (*.mp3)\x00*.mp3\x00All Files (*.*)\x00*.*\x00\x00", nil
|
||||||
case "video":
|
case "VIDEO":
|
||||||
return "Videos (*.webm,*.wmv,*.mpeg,*.mkv,*.mp4,*.avi,*.mov,*.flv)\x00*.webm;*.wmv;*.mpeg;*.mkv;*mp4;*.avi;*.mov;*.flv\x00All Files (*.*)\x00*.*\x00\x00", nil
|
return "Videos (*.webm,*.wmv,*.mpeg,*.mkv,*.mp4,*.avi,*.mov,*.flv)\x00*.webm;*.wmv;*.mpeg;*.mkv;*mp4;*.avi;*.mov;*.flv\x00All Files (*.*)\x00*.*\x00\x00", nil
|
||||||
case "custom":
|
case "CUSTOM":
|
||||||
var i int
|
var i int
|
||||||
var filters = "Files ("
|
var filters = "Files ("
|
||||||
for i = 0 ; i<size ; i++ {
|
for i = 0 ; i<size ; i++ {
|
||||||
|
|
|
@ -20,18 +20,28 @@ func (p *FilePickerPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *FilePickerPlugin) handleFilePicker(methodCall interface{}) (reply interface{}, err error) {
|
func (p *FilePickerPlugin) handleFilePicker(methodCall interface{}) (reply interface{}, err error) {
|
||||||
method := methodCall.(plugin.MethodCall)
|
method := methodCall.(plugin.MethodCall).Method
|
||||||
|
arguments := methodCall.(plugin.MethodCall).Arguments.(map[interface{}]interface{})
|
||||||
|
var allowedExtensions []string
|
||||||
|
|
||||||
filter, err := fileFilter(method.Method)
|
// Parse extensions
|
||||||
if err != nil {
|
if arguments != nil && arguments["allowedExtensions"] != nil {
|
||||||
return nil, errors.Wrap(err, "failed to get filter")
|
allowedExtensions = make([]string, len(arguments["allowedExtensions"].([]interface{})))
|
||||||
|
for i := range arguments["allowedExtensions"].([]interface{}) {
|
||||||
|
allowedExtensions[i] = arguments["allowedExtensions"].([]interface{})[i].(string)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectMultiple, ok := method.Arguments.(bool)
|
selectMultiple, ok := arguments["allowMultipleSelection"].(bool) //method.Arguments.(bool)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.Wrap(err, "invalid format for argument, not a bool")
|
return nil, errors.Wrap(err, "invalid format for argument, not a bool")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filter, err := fileFilter(method, allowedExtensions, len(allowedExtensions), selectMultiple)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed to get filter")
|
||||||
|
}
|
||||||
|
|
||||||
if selectMultiple {
|
if selectMultiple {
|
||||||
filePaths, _, err := dlgs.FileMulti("Select one or more files", filter)
|
filePaths, _, err := dlgs.FileMulti("Select one or more files", filter)
|
||||||
if err != nil {
|
if err != 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.6.2
|
version: 1.6.3+1
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
|
Loading…
Reference in New Issue