[local_auth] Switch to Kotlin Pigeon#11482
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. Part of flutter/flutter#158287
| private final Lifecycle lifecycle; | ||
| private final FragmentActivity activity; | ||
| private final AuthCompletionHandler completionHandler; | ||
| private final Messages.AuthStrings strings; |
There was a problem hiding this comment.
This was just an opportunistic fix while I was in the file; the IDE flagged that we never actually read this value (it's used in the constructor where it's passed in, but never outside that, so doesn't need to be stored).
There was a problem hiding this comment.
Code Review
This pull request updates the local_auth_android package to version 2.0.8, migrating the internal Pigeon implementation from Java to Kotlin. Key changes include updating the build configuration to target Java 17, replacing the generated Java Messages class with a Kotlin equivalent, and refactoring the plugin and its tests to use a new callback-based API. Feedback suggests adding @JvmName to the completeWithValue utility function to improve interoperability when called from Java code.
| fun <T> completeWithError(callback: (Result<@JvmSuppressWildcards T>) -> Unit, failure: Throwable) { | ||
| callback(Result.failure(failure)) | ||
| } | ||
|
|
||
| fun <T> completeWithValue(callback: (Result<@JvmSuppressWildcards T>) -> Unit, value: T) { | ||
| callback(Result.success(value)) | ||
| } |
There was a problem hiding this comment.
When exposing Kotlin functions to Java that involve kotlin.Result in their signature (even as a type argument in a lambda), it is a best practice to use @JvmName to ensure the method names are not mangled by the Kotlin compiler and remain easily callable from Java. While mangling might not occur for Function1 type arguments in all Kotlin versions, explicitly naming them improves interoperability and prevents potential build issues in different environments.
| fun <T> completeWithError(callback: (Result<@JvmSuppressWildcards T>) -> Unit, failure: Throwable) { | |
| callback(Result.failure(failure)) | |
| } | |
| fun <T> completeWithValue(callback: (Result<@JvmSuppressWildcards T>) -> Unit, value: T) { | |
| callback(Result.success(value)) | |
| } | |
| fun <T> completeWithError(callback: (Result<@JvmSuppressWildcards T>) -> Unit, failure: Throwable) { | |
| callback(Result.failure(failure)) | |
| } | |
| @JvmName("completeWithValue") | |
| fun <T> completeWithValue(callback: (Result<@JvmSuppressWildcards T>) -> Unit, value: T) { | |
| callback(Result.success(value)) | |
| } |
| .build(); | ||
| new AuthStrings("a reason", "a hint", "cancel", "sign in"); | ||
|
|
||
| static final AuthOptions defaultOptions = new AuthOptions(false, false, false); |
There was a problem hiding this comment.
nit: add /* biometrics */ like comments so we know what these values represent.
There was a problem hiding this comment.
Done.
(Longer term we may add a Pigeon Kotlin generator option to generate builders, for a more Java-like experience when using it from Java code.)
…er#185287) flutter/packages@c2e3d1f...01c505f 2026-04-20 engine-flutter-autoroll@skia.org Roll Flutter from 8e8a194 to 2844af6 (13 revisions) (flutter/packages#11531) 2026-04-17 stuartmorgan@google.com [google_maps_fluter] Switch to Kotlin Pigeon (flutter/packages#11522) 2026-04-17 engine-flutter-autoroll@skia.org Roll Flutter (stable) from db50e20 to cc0734a (8 revisions) (flutter/packages#11525) 2026-04-17 engine-flutter-autoroll@skia.org Roll Flutter from 31f1802 to 8e8a194 (22 revisions) (flutter/packages#11523) 2026-04-17 stuartmorgan@google.com [google_maps_flutter] Fix various Java warnings (flutter/packages#11516) 2026-04-16 srawlins@google.com [google_maps_flutter] Use super parameters in more places in examples (flutter/packages#11517) 2026-04-16 engine-flutter-autoroll@skia.org Roll Flutter from c1b14e9 to 31f1802 (46 revisions) (flutter/packages#11518) 2026-04-15 stuartmorgan@google.com [tool] Update java formatter (flutter/packages#11508) 2026-04-15 stuartmorgan@google.com [quick_actions] Remove manual thread hop in Android response (flutter/packages#11445) 2026-04-15 49699333+dependabot[bot]@users.noreply.github.com Bump lewagon/wait-on-check-action from 1.6.0 to 1.7.0 in the all-github-actions group (flutter/packages#11510) 2026-04-14 magder@google.com Skip dependabot updates for minor versions of gradle and kotlin (flutter/packages#11509) 2026-04-14 chick.developer@gmail.com [go_router] Fix pop() restoring stale configuration when route has onExit (flutter/packages#11241) 2026-04-14 stuartmorgan@google.com [url_launcher] Switch to Kotlin Pigeon (flutter/packages#11473) 2026-04-14 okorohelijah@google.com [pr-fix] Run all flutter/packages macOS tests using Xcode 26 and iOS 26 simulator (flutter/packages#10635) 2026-04-14 bolling.ludwig@gmail.com [camera_platform_interface] Add setJpegImageQuality method (flutter/packages#11454) 2026-04-14 engine-flutter-autoroll@skia.org Roll Flutter from 2fa45e0 to c1b14e9 (19 revisions) (flutter/packages#11506) 2026-04-14 stuartmorgan@google.com [local_auth] Switch to Kotlin Pigeon (flutter/packages#11482) 2026-04-13 fluttergithub-bot@google.com Sync release-go_router to main (flutter/packages#11499) 2026-04-13 slater.jay@gmail.com [mustache_template] Fix auto-generated specification tests, run with `dart test` (flutter/packages#11056) 2026-04-13 engine-flutter-autoroll@skia.org Roll Flutter from bf18e39 to 2fa45e0 (19 revisions) (flutter/packages#11497) 2026-04-10 engine-flutter-autoroll@skia.org Roll Flutter from 81c87ea to bf18e39 (18 revisions) (flutter/packages#11488) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Replaces the Java Pigeon generator with the Kotlin Pigeon generator, and adjusts the project accordingly:
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