Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 14a2547

Browse files
committed
[image_picker] fix bug, sometimes double click cancel button will crash
1 parent 91e1c38 commit 14a2547

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

packages/image_picker/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.5+1
2+
3+
* Fix a bug, sometimes double click cancel button will crash.
4+
15
## 0.6.5
26

37
* Set maximum duration for video recording.

packages/image_picker/ios/Classes/FLTImagePickerPlugin.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,10 @@ - (void)imagePickerController:(UIImagePickerController *)picker
327327

328328
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
329329
[_imagePickerController dismissViewControllerAnimated:YES completion:nil];
330+
if (!self.result) {
331+
return;
332+
}
330333
self.result(nil);
331-
332334
self.result = nil;
333335
_arguments = nil;
334336
}

packages/image_picker/ios/Tests/ImagePickerPluginTests.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ - (void)testPluginPickVideoDeviceBack {
6161
UIImagePickerControllerCameraDeviceRear);
6262
}
6363

64+
- (void)testPluginPickImageDeviceCancel {
65+
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
66+
return;
67+
}
68+
FLTImagePickerPlugin *plugin =
69+
[[FLTImagePickerPlugin alloc] initWithViewController:[UIViewController new]];
70+
FlutterMethodCall *call =
71+
[FlutterMethodCall methodCallWithMethodName:@"pickImage"
72+
arguments:@{@"source" : @(0), @"cameraDevice" : @(1)}];
73+
[plugin handleMethodCall:call
74+
result:^(id _Nullable r){
75+
}];
76+
// todo test imagePickerControllerDidCancel when result is nil
77+
78+
}
79+
6480
- (void)testPluginPickVideoDeviceFront {
6581
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
6682
return;

packages/image_picker/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: image_picker
22
description: Flutter plugin for selecting images from the Android and iOS image
33
library, and taking new pictures with the camera.
44
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker
5-
version: 0.6.5
5+
version: 0.6.5+1
66

77
flutter:
88
plugin:

0 commit comments

Comments
 (0)