Addresses onFileLoading status callback on iOS 14+ (#577)

This commit is contained in:
Miguel Ruivo 2021-01-31 17:28:09 +00:00
parent 9500baac97
commit faeef3aa4d
6 changed files with 18 additions and 7 deletions

View File

@ -1,3 +1,6 @@
## 2.1.6
- Addresses an issue on iOS 14 and later where events `onFileLoading` events weren't being provided ([#577](https://github.com/miguelpruivo/flutter_file_picker/issues/577)).
## 2.1.5+1
- Web: Updates `size` property from `PlatformFile` to be in bytes instead of kb;
- Applies minor refactor to example app. Thank you @Abhishek01039;

View File

@ -1 +1 @@
32b17685cd2c55cd4f786d731516419d
d14c55479469c81e352606cc6bcd0dc0

View File

@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class FilePickerDemo extends StatefulWidget {
@override

View File

@ -387,6 +387,10 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
self.group = dispatch_group_create();
if(self->_eventSink != nil) {
self->_eventSink([NSNumber numberWithBool:YES]);
}
for (PHPickerResult *result in results) {
dispatch_group_enter(_group);
[result.itemProvider loadFileRepresentationForTypeIdentifier:@"public.item" completionHandler:^(NSURL * _Nullable url, NSError * _Nullable error) {
@ -424,6 +428,9 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
dispatch_group_notify(_group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
self->_group = nil;
if(self->_eventSink != nil) {
self->_eventSink([NSNumber numberWithBool:NO]);
}
[self handleResult:urls];
});
}

View File

@ -20,8 +20,10 @@ class FilePickerResult {
///
/// Only available on IO. Throws `UnsupportedError` on Web.
List<String> get paths => files
.map((file) =>
kIsWeb ? throw UnsupportedError('Unsupported on Web') : file.path)
.map((file) => kIsWeb
? throw UnsupportedError(
'Picking paths is unsupported on Web. Please, use bytes property instead.')
: file.path)
.toList();
/// A `List<String>` containing all names from picked files with its extensions.

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: 2.1.5+1
version: 2.1.6
dependencies:
flutter: