Skip to content

[file_selector] Switch to Kotlin Pigeon#11479

Open
stuartmorgan-g wants to merge 4 commits intoflutter:mainfrom
stuartmorgan-g:kotlin-pigeon-file-selector
Open

[file_selector] Switch to Kotlin Pigeon#11479
stuartmorgan-g wants to merge 4 commits intoflutter:mainfrom
stuartmorgan-g:kotlin-pigeon-file-selector

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.

This does not attempt to fix the pre-existing invalid use of null paths described in flutter/flutter#159568, but the behavior does change slightly from an IllegalStateException (which came from the Java builder) to a NullPointerException (from trying to assign to a non-null Kotlin field).

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

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.

This does not attempt to fix the pre-existing invalid use of null paths
described in flutter/flutter#159568, but the
behavior does change slightly from an IllegalStateException (which came
from the Java builder) to a NullPointerException (from trying to assign
to a non-null Kotlin field).

Part of flutter/flutter#158287
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 file_selector_android package to use Kotlin Pigeon for its internal implementation. Key changes include updating the CHANGELOG.md and pubspec.yaml for version and dependency updates, modifying build.gradle.kts to incorporate Kotlin plugins and compiler options, and replacing the Java-generated Pigeon API with a new Kotlin-generated one. Existing Java files (FileSelectorApiImpl.java, FileSelectorAndroidPlugin.java) are refactored to integrate with the new Kotlin API, including changes to method signatures and error handling. New Kotlin utility files (ResultUtils.kt, TestResultUtils.kt) are added to support Kotlin Result types and facilitate testing. The Dart-generated API (file_selector_api.g.dart) is also updated to reflect the new Pigeon version and error handling. A review comment highlights an incorrect package name in TestResultUtils.kt that needs to be corrected, along with its corresponding import in FileSelectorAndroidPluginTest.java.

@github-actions github-actions bot removed the CICD Run CI/CD label Apr 9, 2026
@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label Apr 9, 2026
@github-actions github-actions bot removed the CICD Run CI/CD label Apr 9, 2026
@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label Apr 9, 2026
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.

1 participant