Fixes an issue that could result in a crash when selecting a media item twice (#518)
This commit is contained in:
parent
2aafd1131c
commit
fe19d20270
|
@ -1,3 +1,6 @@
|
|||
## 2.1.1
|
||||
iOS: Fixes an issue that could result in a crash when selecting a media item twice. ([#518](https://github.com/miguelpruivo/flutter_file_picker/issues/518)).
|
||||
|
||||
## 2.1.0
|
||||
Adds `withReadStream` that allows bigger files to be streamed read into a `Stream<List<int>>`. Thanks @redsolver.
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
@property (nonatomic) MPMediaPickerController *audioPickerController;
|
||||
@property (nonatomic) NSArray<NSString *> * allowedExtensions;
|
||||
@property (nonatomic) BOOL loadDataToMemory;
|
||||
@property (nonatomic) dispatch_group_t group;
|
||||
@end
|
||||
|
||||
@implementation FilePickerPlugin
|
||||
|
@ -362,6 +363,10 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
|
|||
|
||||
-(void)picker:(PHPickerViewController *)picker didFinishPicking:(NSArray<PHPickerResult *> *)results API_AVAILABLE(ios(14)){
|
||||
|
||||
if(self.group != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log(@"Picker:%@ didFinishPicking:%@", picker, results);
|
||||
|
||||
[picker dismissViewControllerAnimated:YES completion:nil];
|
||||
|
@ -375,15 +380,15 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
|
|||
|
||||
NSMutableArray<NSURL *> * urls = [[NSMutableArray alloc] initWithCapacity:results.count];
|
||||
|
||||
dispatch_group_t group = dispatch_group_create();
|
||||
self.group = dispatch_group_create();
|
||||
|
||||
for (PHPickerResult *result in results) {
|
||||
dispatch_group_enter(group);
|
||||
dispatch_group_enter(_group);
|
||||
[result.itemProvider loadFileRepresentationForTypeIdentifier:@"public.item" completionHandler:^(NSURL * _Nullable url, NSError * _Nullable error) {
|
||||
|
||||
if(url == nil) {
|
||||
Log("Could not load the picked given file: %@", error);
|
||||
dispatch_group_leave(group);
|
||||
dispatch_group_leave(self->_group);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -408,11 +413,12 @@ didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls{
|
|||
}
|
||||
|
||||
[urls addObject:cachedUrl];
|
||||
dispatch_group_leave(group);
|
||||
dispatch_group_leave(self->_group);
|
||||
}];
|
||||
}
|
||||
|
||||
dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
|
||||
dispatch_group_notify(_group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{
|
||||
self->_group = nil;
|
||||
[self handleResult:urls];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ class PlatformFile {
|
|||
this.bytes = data['bytes'],
|
||||
this.size = data['size'];
|
||||
|
||||
/// The absolute path for a cached copy of this file. It can be used to create a
|
||||
/// a file instance with a descriptor for the given path.
|
||||
/// The absolute path for a cached copy of this file. It can be used to create a
|
||||
/// file instance with a descriptor for the given path.
|
||||
/// ```
|
||||
/// final File myFile = File(platformFile.path);
|
||||
/// ```
|
||||
|
|
|
@ -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.0
|
||||
version: 2.1.1
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
|
Loading…
Reference in New Issue