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

Commit

Permalink
[image_picker] Fix a crash when user takes a photo using devices unde…
Browse files Browse the repository at this point in the history
…r iOS 11 (#1862)
  • Loading branch information
Chris Yang committed Jul 16, 2019
1 parent f33f695 commit e543129
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.0+17

* iOS: Fix a crash when user captures image from the camera with devices under iOS 11.

## 0.6.0+16

* iOS Simulator: fix hang after trying to take an image from the non-existent camera.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ - (void)setUp {
self.testBundle = [NSBundle bundleForClass:self.class];
}

- (void)getAssetFromImagePickerInfoShouldReturnNilIfNotAvailable {
NSDictionary *mockData = @{};
XCTAssertNil([FLTImagePickerPhotoAssetUtil getAssetFromImagePickerInfo:mockData]);
}

- (void)testSaveImageWithOriginalImageData_ShouldSaveWithTheCorrectExtentionAndMetaData {
// test jpg
NSData *dataJPG = [NSData dataWithContentsOfFile:[self.testBundle pathForResource:@"jpgImage"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface FLTImagePickerPhotoAssetUtil : NSObject

+ (PHAsset *)getAssetFromImagePickerInfo:(NSDictionary *)info;
+ (nullable PHAsset *)getAssetFromImagePickerInfo:(NSDictionary *)info;

// Save image with correct meta data and extention copied from the original asset.
// maxWidth and maxHeight are used only for GIF images.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ + (PHAsset *)getAssetFromImagePickerInfo:(NSDictionary *)info {
return [info objectForKey:UIImagePickerControllerPHAsset];
}
NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
if (!referenceURL) {
return nil;
}
PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithALAssetURLs:@[ referenceURL ]
options:nil];
return result.firstObject;
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors:
- Rhodes Davis Jr. <rody.davis.jr@gmail.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker

version: 0.6.0+16
version: 0.6.0+17

flutter:
plugin:
Expand Down

0 comments on commit e543129

Please sign in to comment.