Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/image_picker/image_picker_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.13+8

* Replaces deprecated `kUTTypeImage` and `kUTTypeMovie` with `UTTypeImage` and `UTTypeMovie` to fix iOS 15+ deprecation warnings.

## 0.8.13+7

* Updates pigeon dev_dependency to ^27.3.2 for analyzer 14 compatibility.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import <PhotosUI/PHPhotoLibrary+PhotosUISupport.h>
#import <PhotosUI/PhotosUI.h>
#import <UIKit/UIKit.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

#import "./include/image_picker_ios/messages.g.h"
#import "FLTImagePickerImageUtil.h"
Expand Down Expand Up @@ -127,10 +128,18 @@ - (void)launchUIImagePickerWithSource:(nonnull FLTSourceSpecification *)source
imagePickerController.delegate = self;
NSMutableArray<NSString *> *mediaTypes = [[NSMutableArray alloc] init];
if (context.includeImages) {
[mediaTypes addObject:(NSString *)kUTTypeImage];
NSString *imageType = (NSString *)kUTTypeImage;
if (@available(iOS 14.0, *)) {
imageType = UTTypeImage.identifier;
}
[mediaTypes addObject:imageType];
}
if (context.includeVideo) {
[mediaTypes addObject:(NSString *)kUTTypeMovie];
NSString *movieType = (NSString *)kUTTypeMovie;
if (@available(iOS 14.0, *)) {
movieType = UTTypeMovie.identifier;
}
[mediaTypes addObject:movieType];
imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
}
Comment on lines 130 to 144

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This code can be simplified by initializing the type variables with their fallback values directly, avoiding the need for the else blocks and making the code more concise and readable.

  if (context.includeImages) {
    NSString *imageType = (NSString *)kUTTypeImage;
    if (@available(iOS 14.0, *)) {
      imageType = UTTypeImage.identifier;
    }
    [mediaTypes addObject:imageType];
  }
  if (context.includeVideo) {
    NSString *movieType = (NSString *)kUTTypeMovie;
    if (@available(iOS 14.0, *)) {
      movieType = UTTypeMovie.identifier;
    }
    [mediaTypes addObject:movieType];
    imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
  }

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied — the legacy kUTType constants are now the default value and the modern UTType overrides them on iOS 14+, which removes the else branches. Pushed in 9df0432.

imagePickerController.mediaTypes = mediaTypes;
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: image_picker_ios
description: iOS implementation of the image_picker plugin.
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 0.8.13+7
version: 0.8.13+8

environment:
sdk: ^3.10.0
Expand Down