This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed
packages/image_picker/image_picker Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 1+ ## 0.6.6+4
2+
3+ * Fix bug, sometimes double click cancel button will crash.
4+
15## 0.6.6+3
26
37* Update README
Original file line number Diff line number Diff line change @@ -326,8 +326,10 @@ - (void)imagePickerController:(UIImagePickerController *)picker
326326
327327- (void )imagePickerControllerDidCancel : (UIImagePickerController *)picker {
328328 [_imagePickerController dismissViewControllerAnimated: YES completion: nil ];
329+ if (!self.result ) {
330+ return ;
331+ }
329332 self.result (nil );
330-
331333 self.result = nil ;
332334 _arguments = nil ;
333335}
Original file line number Diff line number Diff line change 1010@interface FLTImagePickerPlugin (Test)
1111@property (copy , nonatomic ) FlutterResult result;
1212- (void )handleSavedPath : (NSString *)path ;
13+ - (void )imagePickerControllerDidCancel : (UIImagePickerController *)picker ;
1314@end
1415
1516@interface ImagePickerPluginTests : XCTestCase
@@ -66,6 +67,25 @@ - (void)testPluginPickVideoDeviceBack {
6667 UIImagePickerControllerCameraDeviceRear);
6768}
6869
70+ - (void )testPluginPickImageDeviceCancelClickMultipleTimes {
71+ if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
72+ return ;
73+ }
74+ FLTImagePickerPlugin *plugin =
75+ [[FLTImagePickerPlugin alloc ] initWithViewController: [UIViewController new ]];
76+ FlutterMethodCall *call =
77+ [FlutterMethodCall methodCallWithMethodName: @" pickImage"
78+ arguments: @{@" source" : @(0 ), @" cameraDevice" : @(1 )}];
79+ [plugin handleMethodCall: call
80+ result: ^(id _Nullable r){
81+ }];
82+ plugin.result = ^(id result) {
83+
84+ };
85+ [plugin imagePickerControllerDidCancel: [plugin getImagePickerController ]];
86+ [plugin imagePickerControllerDidCancel: [plugin getImagePickerController ]];
87+ }
88+
6989- (void )testPluginPickVideoDeviceFront {
7090 if (![UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
7191 return ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: image_picker
22description : Flutter plugin for selecting images from the Android and iOS image
33 library, and taking new pictures with the camera.
44homepage : https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker
5- version : 0.6.6+3
5+ version : 0.6.6+4
66
77flutter :
88 plugin :
You can’t perform that action at this time.
0 commit comments