Skip to content
Merged
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+6

* Replaces deprecated `kUTTypeGIF` with `UTTypeGIF` to fix iOS 15+ deprecation warnings.

## 0.8.13+5

* Fixes camera confirmation buttons (e.g., Retake/Use Photo) taps passing through to the underlying Flutter UI while the picker is dismissing on some iOS versions (e.g., iOS 26).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#import "FLTImagePickerImageUtil.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

@interface GIFInfo ()

Expand Down Expand Up @@ -117,7 +118,13 @@ + (GIFInfo *)scaledGIFImage:(NSData *)data
maxHeight:(NSNumber *)maxHeight {
NSMutableDictionary<NSString *, id> *options = [NSMutableDictionary dictionary];
options[(NSString *)kCGImageSourceShouldCache] = @YES;
options[(NSString *)kCGImageSourceTypeIdentifierHint] = (NSString *)kUTTypeGIF;
NSString *gifTypeIdentifier;
if (@available(iOS 14.0, *)) {
gifTypeIdentifier = UTTypeGIF.identifier;
} else {
gifTypeIdentifier = (NSString *)kUTTypeGIF;
}
Comment on lines +122 to +126
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To improve consistency with the pattern used in FLTImagePickerPhotoAssetUtil.m and to enhance readability, consider defining the GIF type identifier in a local variable before using it. This separates the logic for determining the identifier from its usage and avoids repeating the dictionary key.

Suggested change
if (@available(iOS 14.0, *)) {
options[(NSString *)kCGImageSourceTypeIdentifierHint] = UTTypeGIF.identifier;
} else {
options[(NSString *)kCGImageSourceTypeIdentifierHint] = (NSString *)kUTTypeGIF;
}
NSString *gifTypeIdentifier;
if (@available(iOS 14.0, *)) {
gifTypeIdentifier = UTTypeGIF.identifier;
} else {
gifTypeIdentifier = (NSString *)kUTTypeGIF;
}
options[(NSString *)kCGImageSourceTypeIdentifierHint] = gifTypeIdentifier;
References
  1. The repository style guide (lines 10-12) states that code should follow relevant style guides for each language. The suggestion to improve consistency and avoid repetition aligns with general Objective-C best practices for writing maintainable and readable code. (link)

options[(NSString *)kCGImageSourceTypeIdentifierHint] = gifTypeIdentifier;

CGImageSourceRef imageSource =
CGImageSourceCreateWithData((__bridge CFDataRef)data, (__bridge CFDictionaryRef)options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import "FLTImagePickerMetaDataUtil.h"

#import <MobileCoreServices/MobileCoreServices.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

@implementation FLTImagePickerPhotoAssetUtil

Expand Down Expand Up @@ -98,8 +99,14 @@ + (NSString *)saveImageWithMetaData:(NSDictionary *)metaData
+ (NSString *)saveImageWithMetaData:(NSDictionary *)metaData
gifInfo:(GIFInfo *)gifInfo
path:(NSString *)path {
CFStringRef imageType;
if (@available(iOS 14.0, *)) {
imageType = (__bridge CFStringRef)UTTypeGIF.identifier;
} else {
imageType = kUTTypeGIF;
}
CGImageDestinationRef destination = CGImageDestinationCreateWithURL(
(__bridge CFURLRef)[NSURL fileURLWithPath:path], kUTTypeGIF, gifInfo.images.count, NULL);
(__bridge CFURLRef)[NSURL fileURLWithPath:path], imageType, gifInfo.images.count, NULL);

NSDictionary *frameProperties = @{
(__bridge NSString *)kCGImagePropertyGIFDictionary : @{
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+5
version: 0.8.13+6

environment:
sdk: ^3.10.0
Expand Down