From 2382cf44dcaf3a89759fb7b61b4546745334e28a Mon Sep 17 00:00:00 2001 From: LinXunFeng Date: Wed, 30 Oct 2024 16:33:09 +0800 Subject: [PATCH 1/2] Safely call the result block --- ios/Classes/FilePickerPlugin.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ios/Classes/FilePickerPlugin.m b/ios/Classes/FilePickerPlugin.m index 09b36cab..6913ae34 100644 --- a/ios/Classes/FilePickerPlugin.m +++ b/ios/Classes/FilePickerPlugin.m @@ -665,8 +665,10 @@ - (void)presentationControllerDidDismiss:(UIPresentationController *)controller #ifdef PICKER_AUDIO - (void)mediaPickerDidCancel:(MPMediaPickerController *)controller { Log(@"FilePicker canceled"); - _result(nil); - _result = nil; + if (self.result != nil) { + self.result(nil); + self.result = nil; + } [controller dismissViewControllerAnimated:YES completion:NULL]; } #endif // PICKER_AUDIO @@ -674,8 +676,10 @@ - (void)mediaPickerDidCancel:(MPMediaPickerController *)controller { #ifdef PICKER_DOCUMENT - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller { Log(@"FilePicker canceled"); - _result(nil); - _result = nil; + if (self.result != nil) { + self.result(nil); + self.result = nil; + } [controller dismissViewControllerAnimated:YES completion:NULL]; } #endif // PICKER_DOCUMENT @@ -683,8 +687,10 @@ - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller #ifdef PICKER_MEDIA - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { Log(@"FilePicker canceled"); - _result(nil); - _result = nil; + if (self.result != nil) { + self.result(nil); + self.result = nil; + } [picker dismissViewControllerAnimated:YES completion:NULL]; } #endif From 3247e542e70c2d59971db67331e720067853367b Mon Sep 17 00:00:00 2001 From: LinXunFeng Date: Wed, 30 Oct 2024 16:34:57 +0800 Subject: [PATCH 2/2] bump hotfix version --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fad94a8..1999f9a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 8.1.4 +### iOS +- Fixes a crash when sometimes user swipe the modal down and call it again. [1357](https://github.com/miguelpruivo/flutter_file_picker/issues/1357) + ## 8.1.3 ### Android - Fixes a null object reference error [#1604](https://github.com/miguelpruivo/flutter_file_picker/issues/1604) diff --git a/pubspec.yaml b/pubspec.yaml index 6624f78c..360145ca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A package that allows you to use a native file explorer to pick sin homepage: https://github.com/miguelpruivo/plugins_flutter_file_picker repository: https://github.com/miguelpruivo/flutter_file_picker issue_tracker: https://github.com/miguelpruivo/flutter_file_picker/issues -version: 8.1.3 +version: 8.1.4 dependencies: flutter: