[image_picker_ios] Return an error for undecodable image data#12267
[image_picker_ios] Return an error for undecodable image data#12267TeddyYeung wants to merge 1 commit into
Conversation
PHPicker can provide image-conforming data that UIImage cannot decode. Complete the save operation with invalid_image instead of passing a nil image to the save path.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the iOS implementation of the image_picker plugin to handle cases where selected image data cannot be decoded. In FLTPHPickerSaveImageToPathOperation.m, a check has been added to verify if the UIImage is nil after initialization; if so, the operation completes with an 'invalid_image' FlutterError. A corresponding unit test has been added to PickerSaveImageToPathOperationTests.m to verify this behavior, and the package version has been bumped to 0.8.13+7 in both pubspec.yaml and CHANGELOG.md. There are no review comments to address.
PHPickercan provide data for a type that conforms toUTTypeImageeven whenUIImagecannot decode the bytes. The linked issue reports this with an AVIF selection. The existing path continues with anilimage and can treat the selection as successfully saved.This change completes the operation with the existing
invalid_imageerror when decoding fails. It also adds a regression test that verifies the callback returns no path and that theNSOperationfinishes.Fixes flutter/flutter#132154
No public API documentation changes are needed because this uses the existing image-picker error contract.
Tests run:
flutter_plugin_tools format --packages image_picker_ios --fail-on-changeflutter_plugin_tools analyze --ios --packages image_picker_iosflutter_plugin_tools dart-test --packages image_picker_iosflutter_plugin_tools native-test --ios --no-integration --packages image_picker_iosflutter_plugin_tools validate --packages image_picker_iosflutter_plugin_tools license-check(from packages/image_picker/image_picker_ios) dart pub publish --dry-runPre-Review Checklist
[shared_preferences]///).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