Skip to content

[image_picker] Switch to Kotlin Pigeon#11504

Open
stuartmorgan-g wants to merge 9 commits intoflutter:mainfrom
stuartmorgan-g:kotlin-pigeon-image-picker
Open

[image_picker] Switch to Kotlin Pigeon#11504
stuartmorgan-g wants to merge 9 commits intoflutter:mainfrom
stuartmorgan-g:kotlin-pigeon-image-picker

Conversation

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

Replaces the Java Pigeon generator with the Kotlin Pigeon generator, and adjusts the project accordingly:

  • Adds Kotlin build setings to Gradle.
  • Updates API signatures for Kotlin/Java differences.
  • Adds generic Java/Kotlin compat shim to create Result objects from Java, since those haven't been added to the Pigeon generator yet.
  • Updates tests to use constructors instead of builders, since the Kotlin generator doesn't create builders.
  • Updates tests to use a Java/Kotlin compat shim to read Kotlin Result values, instead of mocking the Java Pigeon response object.

Part of flutter/flutter#158287

Pre-Review Checklist

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

Copy link
Copy Markdown

@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 migrates the internal Pigeon implementation from Java to Kotlin, updating the build configuration and regenerating the messaging layer. The ImagePickerDelegate and ImagePickerPlugin have been refactored to use Kotlin-style callbacks and result handling. Feedback was provided regarding the high verbosity of the new callback type signatures in Java, suggesting the use of wrappers to improve code readability.

Comment on lines +100 to +102
public final @NonNull Function1<
? super @NotNull Result<? extends @NotNull List<@NotNull String>>, @NotNull Unit>
callback;
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

The type signature for the callback is extremely verbose in Java. While this is dictated by the Kotlin Pigeon generator's use of Kotlin's Result type, it significantly impacts readability. Consider if a simpler wrapper or functional interface could be used to encapsulate this complexity in the future.

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

Labels

CICD Run CI/CD p: image_picker platform-android triage-android Should be looked at in Android triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant