Skip to content

[image_picker_ios] Return an error for undecodable image data#12267

Open
TeddyYeung wants to merge 1 commit into
flutter:mainfrom
TeddyYeung:codex/image-picker-ios-avif-completion
Open

[image_picker_ios] Return an error for undecodable image data#12267
TeddyYeung wants to merge 1 commit into
flutter:mainfrom
TeddyYeung:codex/image-picker-ios-avif-completion

Conversation

@TeddyYeung

@TeddyYeung TeddyYeung commented Jul 22, 2026

Copy link
Copy Markdown

PHPicker can provide data for a type that conforms to UTTypeImage even when UIImage cannot decode the bytes. The linked issue reports this with an AVIF selection. The existing path continues with a nil image and can treat the selection as successfully saved.

This change completes the operation with the existing invalid_image error when decoding fails. It also adds a regression test that verifies the callback returns no path and that the NSOperation finishes.

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-change
  • flutter_plugin_tools analyze --ios --packages image_picker_ios
  • flutter_plugin_tools dart-test --packages image_picker_ios
  • flutter_plugin_tools native-test --ios --no-integration --packages image_picker_ios
  • flutter_plugin_tools validate --packages image_picker_ios
  • flutter_plugin_tools license-check
  • (from packages/image_picker/image_picker_ios) dart pub publish --dry-run

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

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.
@google-cla

google-cla Bot commented Jul 22, 2026

Copy link
Copy Markdown

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.

@TeddyYeung
TeddyYeung marked this pull request as ready for review July 22, 2026 04:10

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

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[image_picker][iOS] Selecting an AVIF file on iOS causes indefinite loader and no response / crash

1 participant