Skip to content

[local_auth] Convert implementation to Kotlin - #12635

Merged
auto-submit[bot] merged 12 commits into
flutter:mainfrom
stuartmorgan-g:kotlin-local-auth-part-1-impl
Sep 15, 2026
Merged

auto-submit[bot] merged 12 commits into
flutter:mainfrom
stuartmorgan-g:kotlin-local-auth-part-1-impl

Conversation

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

Converts the implementation of the plugin to Kotlin, so that it can be used to dogfood the new async/await support in Pigeon 28 (not added in this PR; this is just to unblock adding that in a later PR).

The process was as described here:

  • Initial conversion was done using the deterministic Android Studio converter
  • I did manual cleanup for some small errors that resulted from the auto-converter, as well as improving nullability in general (e.g., generics in Java can't be annotated, so the auto-converted assumes they are all nullable)
  • I fixed warnings and suggestions flagged by Android Studio
  • I had Gemini do a local code review focusing on idiomatic Kotlin, and incorporated some of its suggestions to make code more Kotlin-y and less Java-in-Kotlin.

Tests will be converted in a follow-up PR, so that we aren't making massive changes to implementation and tests in the same PR, since it's intended to be behavior-neutral.

Part of flutter/flutter#188630

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

@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 converts the Android implementation of the local_auth plugin from Java to Kotlin, updating AuthenticationHelper and LocalAuthPlugin alongside their unit tests, and increments the package version to 2.1.0. The review feedback recommends assigning the newly created BiometricPrompt in handleResume to the biometricPrompt member variable to ensure it can be cancelled, and suggests removing redundant empty overrides of DefaultLifecycleObserver methods.

Comment on lines +168 to +174
override fun onDestroy(owner: LifecycleOwner) {}

override fun onStop(owner: LifecycleOwner) {}

override fun onStart(owner: LifecycleOwner) {}

override fun onCreate(owner: LifecycleOwner) {}

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.

medium

These empty overrides of DefaultLifecycleObserver methods are redundant because DefaultLifecycleObserver provides default no-op implementations for all of its methods. Removing them simplifies the class and improves maintainability.

References
  1. Avoid redundant overrides of interface methods that already have default no-op implementations to keep the codebase clean and maintainable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in the Java code, but since it's obviously a no-op to remove these I went ahead and did that.

helper.onAuthenticationError(BiometricPrompt.ERROR_USER_CANCELED, "");

verify(handler).complete(new AuthResult(AuthResultCode.USER_CANCELED, ""));
assertNotNull(result[0]);

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.

This no longer checks this was called only once.

If you make result a ArrayList<> and use result.add(authResult), you could check the size is only 1.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 15, 2026
@auto-submit
auto-submit Bot merged commit c2b58e1 into flutter:main Sep 15, 2026
13 checks passed
@stuartmorgan-g stuartmorgan-g mentioned this pull request Sep 16, 2026
11 tasks done
GhagSagar23 pushed a commit to Kryonex-Labs/flutter that referenced this pull request Sep 16, 2026
…r#192876)

flutter/packages@bebbb57...c2b58e1

2026-09-15 stuartmorgan@google.com [local_auth] Convert implementation
to Kotlin (flutter/packages#12635)
2026-09-15 mhmmd.bayraktar@gmail.com [pigeon] Treat NSNull as null for
non-null Flutter API returns (flutter/packages#12531)
2026-09-15 daniel.leon@cloudsufi.com [espresso] Adopt code-excerpts for
README (flutter/packages#12644)
2026-09-15 daniel.leon@cloudsufi.com [pointer_interceptor] Adopt
code-excerpts for README (flutter/packages#12641)
2026-09-15 47866232+chunhtai@users.noreply.github.com [ci] Checks
unmerged batch release sync back before next release
(flutter/packages#12868)
2026-09-15 puneetkukreja98@gmail.com [material_ui] Add sortIconBuilder
to DataTable, PaginatedDataTable, and DataTableThemeData
(flutter/packages#12645)
2026-09-15 10687576+bparrishMines@users.noreply.github.com
[cross_file_platform_interface] Platform interface implementation of
`cross_file` (flutter/packages#12825)
2026-09-15 10687576+bparrishMines@users.noreply.github.com [cross_file]
Move cross_file into a federated cross_file directory
(flutter/packages#12869)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode 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
auto-submit Bot pushed a commit that referenced this pull request Sep 16, 2026
Following up from #12635, this converts the unit tests from Java to Kotlin. As with that PR, this started with a deterministic Android Studio conversion, then made follow-up fixes manually, including suggestions from a local Gemini review.

The non-test changes are to replace `@VisibleForTesting` with `internal` now that the tests are Kotlin and can therefore access `internal` members. (Also, one very minor refactoring to fix a code suggestion warning in Android Studio.)

Part of flutter/flutter#188630

## Pre-Review Checklist

[^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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: local_auth platform-android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants