@@ -124,50 +124,50 @@ - (void)showPhotoLibrary {
124124
125125- (void )imagePickerController : (UIImagePickerController *)picker
126126 didFinishPickingMediaWithInfo : (NSDictionary <NSString *, id> *)info {
127- NSURL *videoURL = [info objectForKey: UIImagePickerControllerMediaURL];
128- UIImage *image = [info objectForKey: UIImagePickerControllerEditedImage];
129- [_imagePickerController dismissViewControllerAnimated: YES completion: nil ];
130- if (image == nil ) {
131- image = [info objectForKey: UIImagePickerControllerOriginalImage];
132- }
133- image = [self normalizedImage: image];
134-
135- NSNumber *maxWidth = [_arguments objectForKey: @" maxWidth" ];
136- NSNumber *maxHeight = [_arguments objectForKey: @" maxHeight" ];
127+ NSURL *videoURL = [info objectForKey: UIImagePickerControllerMediaURL];
128+ UIImage *image = [info objectForKey: UIImagePickerControllerEditedImage];
129+ [_imagePickerController dismissViewControllerAnimated: YES completion: nil ];
130+ if (image == nil ) {
131+ image = [info objectForKey: UIImagePickerControllerOriginalImage];
132+ }
133+ image = [self normalizedImage: image];
134+
135+ NSNumber *maxWidth = [_arguments objectForKey: @" maxWidth" ];
136+ NSNumber *maxHeight = [_arguments objectForKey: @" maxHeight" ];
137137
138- if (maxWidth != (id )[NSNull null ] || maxHeight != (id )[NSNull null ]) {
139- image = [self scaledImage: image maxWidth: maxWidth maxHeight: maxHeight];
138+ if (maxWidth != (id )[NSNull null ] || maxHeight != (id )[NSNull null ]) {
139+ image = [self scaledImage: image maxWidth: maxWidth maxHeight: maxHeight];
140+ }
141+
142+ if (videoURL != nil ) {
143+ NSData *data = [NSData dataWithContentsOfURL: videoURL];
144+ NSString *guid = [[NSProcessInfo processInfo ] globallyUniqueString ];
145+ NSString *tmpFile = [NSString stringWithFormat: @" image_picker_%@ .MOV" , guid];
146+ NSString *tmpDirectory = NSTemporaryDirectory ();
147+ NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent: tmpFile];
148+
149+ if ([[NSFileManager defaultManager ] createFileAtPath: tmpPath contents: data attributes: nil ]) {
150+ _result (tmpPath);
151+ } else {
152+ _result ([FlutterError errorWithCode: @" create_error"
153+ message: @" Temporary file could not be created"
154+ details: nil ]);
140155 }
141-
142- if (videoURL != nil ) {
143- NSData *data = [NSData dataWithContentsOfURL: videoURL];
144- NSString *guid = [[NSProcessInfo processInfo ] globallyUniqueString ];
145- NSString *tmpFile = [NSString stringWithFormat: @" image_picker_%@ .MOV" , guid];
146- NSString *tmpDirectory = NSTemporaryDirectory ();
147- NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent: tmpFile];
148-
149- if ([[NSFileManager defaultManager ] createFileAtPath: tmpPath contents: data attributes: nil ]) {
150- _result (tmpPath);
151- } else {
152- _result ([FlutterError errorWithCode: @" create_error"
153- message: @" Temporary file could not be created"
154- details: nil ]);
155- }
156+ } else {
157+ NSData *data = UIImageJPEGRepresentation (image, 1.0 );
158+ NSString *guid = [[NSProcessInfo processInfo ] globallyUniqueString ];
159+ NSString *tmpFile = [NSString stringWithFormat: @" image_picker_%@ .jpg" , guid];
160+ NSString *tmpDirectory = NSTemporaryDirectory ();
161+ NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent: tmpFile];
162+
163+ if ([[NSFileManager defaultManager ] createFileAtPath: tmpPath contents: data attributes: nil ]) {
164+ _result (tmpPath);
156165 } else {
157- NSData *data = UIImageJPEGRepresentation (image, 1.0 );
158- NSString *guid = [[NSProcessInfo processInfo ] globallyUniqueString ];
159- NSString *tmpFile = [NSString stringWithFormat: @" image_picker_%@ .jpg" , guid];
160- NSString *tmpDirectory = NSTemporaryDirectory ();
161- NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent: tmpFile];
162-
163- if ([[NSFileManager defaultManager ] createFileAtPath: tmpPath contents: data attributes: nil ]) {
164- _result (tmpPath);
165- } else {
166- _result ([FlutterError errorWithCode: @" create_error"
167- message: @" Temporary file could not be created"
168- details: nil ]);
169- }
166+ _result ([FlutterError errorWithCode: @" create_error"
167+ message: @" Temporary file could not be created"
168+ details: nil ]);
170169 }
170+ }
171171
172172 _result = nil ;
173173 _arguments = nil ;
0 commit comments