Repository navigation
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.Technical debt, code quality, testing, etc.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team
Description
IMPORTANT NOTE: Per the documented policy, PRs migrating existing code will only be accepted from Flutter team members.
I think there a number of compelling reasons that we should use Kotlin for all of our 1P plugins:
- Maintenance benefits:
- Kotlin is a safer language. Notably, it has strong type safety and null handling, like modern Dart, which eliminates whole categories of errors (errors which have caused bugs in our plugin for the entire time I have been on the ecosystem team). It also has a modern concurrency system that has safety benefits over callbacks, guaranteeing that an async operation doesn't have codepaths that complete anything other than exactly once (particularly important for method channels).
- Kotlin is, IMO, more like Dart. The type system, concurrency system, collection operations, etc. are much more similar to Dart than Java's, which I find makes moving between them easier. For the ecosystem team, this is particularly valuable, as we deal with more languages, so the more similar they are the better (and Swift, which we are actively moving to is also more like Dart and Kotlin).
- We plan to remove the Java Pigeon generator, and have therefore switched essentially all of our plugins to the Kotlin generator, so currently most plugins are hybrid. While the Kotlin code is generated rather than human-maintained, there are some mismatches that make the Java code slightly awkward, especially around Pigeon's use of the
ResultKotlin type, leading to shims like this. - The build files for our plugins are all Kotlin now, so replacing Java with Kotlin would reduce the overall number of languages in the repo by one.
- Community benefits:
- The community often looks to our plugins as examples. The
flutter createdefault for a new plugin has been Kotlin for many years now, so our Java code is not as useful an example for other developers. - Relatedly, if we want our plugins to serve as examples of good practices that LLMs will draw from, having them be in the language developers are likely to be using will make them more likely to positively influence generated code.
- Our experience will better match the community's, shaping our development priorities in ways that better align with the community. For instance, I think it's very likely that we would have prioritized adopting modern concurrency in Pigeon's Swift and Kotlin generators if we had been using those languages, since historically Pigeon development has been driven mostly by our own actual usage.
- To the extent that both our
createdefaults and Android's Kotlin-first model encourage Android plugin developers to learn Kotlin, not Java, having our plugin be Kotlin would make community contributions to our plugins (PRs, reviews, etc.) easier. (I would also expect that the increased safety would make reviewing easier in the long term.)
- The community often looks to our plugins as examples. The
Potentially useful references:
- The corresponding Swift umbrella issue.
- The Swift migration design doc, which has some discussion about migration strategies that can be useful. In particular, migrating unit tests and implementations as separate PRs is something I would strongly recommend here, to minimize the potential for regressions.
- My original (now 5 year old!) design doc proposing Kotlin usage, although it's definitely outdated in many respects.
Current status:
- camera
- tests
- espresso
- tests
- file_selector
- google_maps_flutter
- google_sign_in
- image_picker
- tests
- in_app_purchase
- tests
- local_auth
- quick_actions
- shared_preferences
- url_launcher
- video_player
- tests
- webview_flutter
- tests
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.Technical debt, code quality, testing, etc.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team
Activity
stuartmorgan-g commentedon Jun 26, 2026
I also want to capture a suggestion here about an approach for migrating, which I trialed in
local_authas an experiment. This branch has the individual steps I took, which were:local_auth.!, and try to eliminate as many as possible. The previous step can clean up a lot of them, but what's left often exposes latent potential NPEs from our old Java code, where we were passing types that really were nullable into underlying APIs that don't allow nulls.I found the last step valuable as a way to not only improve the code, but to help address one of the main reasons we haven't adopted Kotlin already: the Flutter team has a lot of Java experience, but not much Kotlin experience. Because we don't have veteran Kotlin reviewers, we haven't had a good bootstrapping mechanism for learning the Kotlin-y way to do something. An agent review helps fill that gap because common coding conventions are the kind of thing that LLMs are generally good at surfacing. In my trial, it raised several Kotlin features that I didn't know about, went and learned about, and then adopted, both making the code better and improving my knowledge of Kotlin.
If/when the Android team decides to migrate, I would highly recommend having everyone working on plugins go through this process on a plugin or portion of a plugin (which, I think counterintuitively, means not leveraging the community to do most of the migration), as a way of getting everyone more comfortable with Kotlin.
stuartmorgan-g commentedon Jun 26, 2026
Lastly, capturing the other main argument against this from previous discussions: since the engine is Java, the language consistency argument cuts the other way there. While this proposal reduces the number of languages in flutter/packages, it means everyone whose work is split between the engine and plugins (which I believe is the entire Android team) will increase the number of languages they regularly interact with (until/unless the engine also adopts Kotlin, but I would expect migrating that to be much harder than migrating individual plugins).
[shared_preferences] Convert legacy codepath to Kotlin (#12139)
[shared_preferences] Convert legacy tests to Kotlin (#12193)
[various] Convert example boilerplate from Java to Kotlin (#12201)
[various] Convert example boilerplate from Java to Kotlin (flutter#12201
[local_auth] Convert implementation to Kotlin (#12635)
[local_auth] Convert tests to Kotlin (#12884)
Update Android plugin language guidance (flutter#192906)
[url_launcher] Convert unit tests to Kotlin (#13018)
[google_maps_flutter] Convert unit tests to Kotlin (#13072)
[google_sign_in] Convert unit tests to Kotlin (#13000)
[google_sign_in] Convert implementation to Kotlin (#13005)
[file_selector] Convert unit tests to Kotlin (#13102)