Prevents a crash when a file can't be resolved on Android (#221)

This commit is contained in:
Miguel Ruivo 2020-04-20 00:06:04 +01:00
parent c13124f9bb
commit d94aaaac30
5 changed files with 12 additions and 10 deletions

View File

@ -1,3 +1,7 @@
## 1.6.3+2
* Fixes a crash on Android when a file has an id that can't be resolved and uses a name instead (#221);
* Minor fix on Go (Desktop) - Windows (thanks @marchellodev);
## 1.6.3+1
Addresses an issue with plugin calls on Go (Desktop) - Linux & Windows

View File

@ -71,14 +71,15 @@ public class FileUtils {
id = id.split(":")[1];
}
for (final String contentUriPrefix : contentUriPrefixesToTry) {
final Uri contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.valueOf(id));
try {
final Uri contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.valueOf(id));
final String path = getDataColumn(context, contentUri, null, null);
if (path != null) {
return path;
}
} catch (final Exception e) {
Log.e(TAG, "Something went wrong while retrieving document path: " + e.toString());
return null;
}
}

View File

@ -1,6 +1,6 @@
# file_picker
This Go package implements the host-side of the Flutter [file_picker](https://github.com/miguelpruivo/plugins_flutter_file_picker) plugin.
This Go package implements the host-side of the Flutter [file_picker](https://github.com/miguelpruivo/flutter_file_picker) plugin.
## Usage
@ -11,8 +11,7 @@ package main
import (
... other imports ....
file_picker "github.com/miguelpruivo/plugins_flutter_file_picker/go"
file_picker "github.com/miguelpruivo/flutter_file_picker/go"
)
var options = []flutter.Option{

View File

@ -1,8 +1,6 @@
package file_picker
import (
"strings"
"github.com/gen2brain/dlgs"
"github.com/pkg/errors"
)
@ -21,9 +19,9 @@ func fileFilter(method string, extensions []string, size int, isMulti bool) (str
var i int
var filters = "Files ("
for i = 0 ; i<size ; i++ {
filters += `*.` extensions[i] + `,`
filters += `*.` + extensions[i] + `,`
}
filters += ")\x00*." + resolveType[1] + "\x00All Files (*.*)\x00*.*\x00\x00"
filters += ")"
return filters, nil
default:
return "", errors.New("unknown method")

View File

@ -1,7 +1,7 @@
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.
homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker
version: 1.6.3+1
version: 1.6.3+2
dependencies:
flutter:
@ -9,7 +9,7 @@ dependencies:
flutter_plugin_android_lifecycle: ^1.0.6
environment:
sdk: ">=2.0.0-dev.28.0 <3.0.0"
sdk: ">=2.0.0 <3.0.0"
flutter: ">=1.10.0 <2.0.0"
flutter: