Temporary workaround for #49365 (Flutter)
Adds temporary workaround for (#49365)(https://github.com/flutter/flutter/issues/49365) until 1.14.6 lands on stable channel.
This commit is contained in:
parent
a9cc55f5f5
commit
cabddf7790
|
@ -1,3 +1,7 @@
|
||||||
|
## 1.5.0+1
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
* **Breaking change:** Refactored `FileType` to match lower camelCase Dart guideline (eg. `FileType.ALL` now is `FileType.all`);
|
* **Breaking change:** Refactored `FileType` to match lower camelCase Dart guideline (eg. `FileType.ALL` now is `FileType.all`);
|
||||||
|
|
|
@ -60,7 +60,6 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
public boolean onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
public boolean onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
||||||
|
|
||||||
if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -80,9 +79,9 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
currentItem++;
|
currentItem++;
|
||||||
}
|
}
|
||||||
if (paths.size() > 1) {
|
if (paths.size() > 1) {
|
||||||
FilePickerDelegate.this.finishWithSuccess(paths);
|
finishWithSuccess(paths);
|
||||||
} else {
|
} else {
|
||||||
FilePickerDelegate.this.finishWithSuccess(paths.get(0));
|
finishWithSuccess(paths.get(0));
|
||||||
}
|
}
|
||||||
} else if (data.getData() != null) {
|
} else if (data.getData() != null) {
|
||||||
final Uri uri = data.getData();
|
final Uri uri = data.getData();
|
||||||
|
@ -95,26 +94,27 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
|
|
||||||
if (fullPath != null) {
|
if (fullPath != null) {
|
||||||
Log.i(FilePickerDelegate.TAG, "Absolute file path:" + fullPath);
|
Log.i(FilePickerDelegate.TAG, "Absolute file path:" + fullPath);
|
||||||
FilePickerDelegate.this.finishWithSuccess(fullPath);
|
finishWithSuccess(fullPath);
|
||||||
} else {
|
} else {
|
||||||
FilePickerDelegate.this.finishWithError("unknown_path", "Failed to retrieve path.");
|
finishWithError("unknown_path", "Failed to retrieve path.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FilePickerDelegate.this.finishWithError("unknown_activity", "Unknown activity error, please fill an issue.");
|
finishWithError("unknown_activity", "Unknown activity error, please fill an issue.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FilePickerDelegate.this.finishWithError("unknown_activity", "Unknown activity error, please fill an issue.");
|
finishWithError("unknown_activity", "Unknown activity error, please fill an issue.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_CANCELED) {
|
} else if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_CANCELED) {
|
||||||
Log.i(TAG, "User cancelled the picker request");
|
Log.i(TAG, "User cancelled the picker request");
|
||||||
this.finishWithSuccess(null);
|
finishWithSuccess(null);
|
||||||
return true;
|
return true;
|
||||||
} else if (requestCode == REQUEST_CODE) {
|
} else if (requestCode == REQUEST_CODE) {
|
||||||
this.finishWithError("unknown_activity", "Unknown activity error, please fill an issue.");
|
finishWithError("unknown_activity", "Unknown activity error, please fill an issue.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
if (permissionGranted) {
|
if (permissionGranted) {
|
||||||
this.startFileExplorer();
|
this.startFileExplorer();
|
||||||
} else {
|
} else {
|
||||||
this.finishWithError("read_external_storage_denied", "User did not allowed reading external storage");
|
finishWithError("read_external_storage_denied", "User did not allowed reading external storage");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -159,7 +159,7 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
this.activity.startActivityForResult(intent, REQUEST_CODE);
|
this.activity.startActivityForResult(intent, REQUEST_CODE);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Can't find a valid activity to handle the request. Make sure you've a file explorer installed.");
|
Log.e(TAG, "Can't find a valid activity to handle the request. Make sure you've a file explorer installed.");
|
||||||
this.finishWithError("invalid_format_type", "Can't handle the provided file type.");
|
finishWithError("invalid_format_type", "Can't handle the provided file type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
public void startFileExplorer(final String type, final boolean isMultipleSelection, final MethodChannel.Result result) {
|
public void startFileExplorer(final String type, final boolean isMultipleSelection, final MethodChannel.Result result) {
|
||||||
|
|
||||||
if (!this.setPendingMethodCallAndResult(result)) {
|
if (!this.setPendingMethodCallAndResult(result)) {
|
||||||
FilePickerDelegate.finishWithAlreadyActiveError(result);
|
finishWithAlreadyActiveError(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,8 +183,11 @@ public class FilePickerDelegate implements PluginRegistry.ActivityResultListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishWithSuccess(final Object data) {
|
private void finishWithSuccess(final Object data) {
|
||||||
this.pendingResult.success(data);
|
// Temporary fix, remove this null-check after Flutter Engine 1.14 has landed on stable
|
||||||
this.clearPendingResult();
|
if (this.pendingResult != null) {
|
||||||
|
this.pendingResult.success(data);
|
||||||
|
this.clearPendingResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishWithError(final String errorCode, final String errorMessage) {
|
private void finishWithError(final String errorCode, final String errorMessage) {
|
||||||
|
|
|
@ -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.5.0
|
version: 1.5.0+1
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
|
Loading…
Reference in New Issue