-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[image_picker_ios] Fix deprecated kUTTypeGIF usage #10848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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. |
There was a problem hiding this 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.
| if (@available(iOS 14.0, *)) { | ||
| options[(NSString *)kCGImageSourceTypeIdentifierHint] = UTTypeGIF.identifier; | ||
| } else { | ||
| options[(NSString *)kCGImageSourceTypeIdentifierHint] = (NSString *)kUTTypeGIF; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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
- 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)
|
test-exempt: code refactor with no semantic change |
[image_picker_ios] Fix deprecated kUTTypeGIF usage
This PR replaces the deprecated
kUTTypeGIFconstant with the modernUTTypeGIFAPI to fix iOS 15+ deprecation warnings in the image_picker_ios plugin.Changes:
UniformTypeIdentifiersframework import to affected fileskUTTypeGIFwithUTTypeGIF.identifierfor iOS 14+@available(iOS 14.0, *)checks to maintain backward compatibility with iOS 13The 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 hintFLTImagePickerPhotoAssetUtil.m- Updated GIF destination typeFixes flutter/flutter#181291
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).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-assistbot 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
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