Skip to content

Conversation

@ritoban23
Copy link

[image_picker_ios] Fix deprecated kUTTypeGIF usage

This PR replaces the deprecated kUTTypeGIF constant with the modern UTTypeGIF API to fix iOS 15+ deprecation warnings in the image_picker_ios plugin.

Changes:

  • Added UniformTypeIdentifiers framework import to affected files
  • Replaced kUTTypeGIF with UTTypeGIF.identifier for iOS 14+
  • Added @available(iOS 14.0, *) checks to maintain backward compatibility with iOS 13

The minimum iOS deployment target is 13.0, so the code uses conditional compilation to support both the new API (iOS 14+) and the deprecated API (iOS 13) where necessary.

Files changed:

  • FLTImagePickerImageUtil.m - Updated GIF image source type hint
  • FLTImagePickerPhotoAssetUtil.m - Updated GIF destination type

Fixes flutter/flutter#181291

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses the deprecation of kUTTypeGIF by using the UTTypeGIF API on iOS 14 and newer, with a proper fallback for older versions. The changes are implemented correctly in both FLTImagePickerImageUtil.m and FLTImagePickerPhotoAssetUtil.m, and the version and changelog updates are appropriate. I have one minor suggestion to improve code consistency between the two modified Objective-C files. Otherwise, the changes look good.

Comment on lines +121 to +125
if (@available(iOS 14.0, *)) {
options[(NSString *)kCGImageSourceTypeIdentifierHint] = UTTypeGIF.identifier;
} else {
options[(NSString *)kCGImageSourceTypeIdentifierHint] = (NSString *)kUTTypeGIF;
}

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)

@stuartmorgan-g
Copy link
Collaborator

test-exempt: code refactor with no semantic change

@stuartmorgan-g stuartmorgan-g added the triage-ios Should be looked at in iOS triage label Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: image_picker platform-ios triage-ios Should be looked at in iOS triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FLTImagePickerImageUtil: error: 'kUTTypeGIF' is deprecated, Use UTTypeGIF instead

2 participants