[file_selector] Switch to Kotlin Pigeon#11479
[file_selector] Switch to Kotlin Pigeon#11479stuartmorgan-g wants to merge 4 commits intoflutter:mainfrom
Conversation
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
There was a problem hiding this comment.
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.
Replaces the Java Pigeon generator with the Kotlin Pigeon generator, and adjusts the project accordingly:
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
[shared_preferences]///).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