Kotlin Language Feature Request: support Flutter

Coming back to this thread after 6 months having done a fair bit of flutter work, I don’t think it would happen. The big advantage of Dart for flutter is hot reload that can not be done with Kotlin. Dart is an adequate language, but some of the features I really miss from Kotlin are:

  • nullable types
  • it as default lambda parameter
  • method overloading
  • no semicolons
  • nested classes
  • extension functions
  • enum classes

I have seen several articles lately with people arguing for Kotlin Multiplatform over Flutter, but usually by people that don’t understand flutter.

1 Like

Maybe with Kotlin scripting, it would be to do something similar to what Flutter does with Dart, which can run in interpreted mode or compile to native.

I think it would be easier to add some features, like the ones you listed, to Dart than to support Kotlin in Flutter. The only argument to support Kotlin, I can think of, is that they want to catch Android devs that are used to Kotlin.

Well, the hot reload is actually possible on kotlin. The stateless version is quite easy to do and is actually working in a lot of frameworks. The statefull variant (like dart source code injection) is also possible at least for jvm (Grails actually has this feature). For statically typed language like kotlin there are some tricks to it and would require custom runtime and some kind of mechanism of chain data validation inside the framework (if class is broken somewhere, you need to invalidate all of its dependencies).

It could be done. I am not sure it worth the effort. I am not a mobile developer, but I think that hot restart is sufficient in most cases.

By the way, it is probably possible to modify Dart VM to make it understand kotlin (not transpiling, full language support). It all depends on Google.

I don’t buy your claims on hot reload. For the record, see the video here to make sure we are talking about the same thing: https://flutter.dev/docs/development/tools/hot-reload.

It is actually takes more than the language to have meaningful hot reload. With flutter it is also the whole way that state is handled that helps hot reload to work.

Android itself has had an instant run feature for a long time that claims to be like hot reload, but in my experience was completely unreliable and rarely ever actually worked. So much so that I always just disabled it. Here is a comparison of the 2: https://stackoverflow.com/questions/52050660/difference-between-androids-instant-run-vs-flutters-hot-reload-and-react-nativ

And Hot Restart is definitely not comparable. Imagine working on a screen that requires logging into the app and navigating through several steps to get to that screen. Having to do that every time is a big pain in the butt and part of why hot reload is so game changing.

It would actually also be possible to take the Flutter UI widgets and stack and port it to Kotlin to use for the UI. That way you could actually only code the UI once. You would not have the benefit of all the community flutter libraries, but is possible.

Sorry to reply to such an old thread, but Microsoft have managed to target Flutter from C# using their new Blazor framework - perhaps it’ll serve as an inspiration for how Kotlin might target Flutter?

The solution is called Blutter and there are a few details in this article, which makes reference to a video of it actually working.

As I understand it, Blazor’s renderer was replaced with one that calls the Flutter APIs. Of course, saying “replace the renderer” is a lot simpler than actually doing it!

According to the article that is just a demo and not something that will ship.

But I would love to see the ease of development with the flutter UI but with Kotlin. Jetpack compose is making a flutter like UI, but it isn’t cross platform

Yes, you’re right, it’s just a demo, but it proves that it is possible to leverage Flutter from a language other than Dart. I don’t remember precisely where but there is something somewhere explaining how it was done.

Wanted to add that the Dart language is evolving and becoming more like Kotlin. They recently added extension methods (more appropriately called extension members since it includes properties and operators). Nullable type system is in the works.