We all love Dart. But wouldn’t it be nice if we could combine it with Kotlin? For everything Dart might lack for high-level programming, there's kt.dart. This project ports the Kotlin Standard Library for Dart/Flutter projects. Why choose one when you can have the best of both in a neat package?
As Kotlin usage continues to grow and improve, one thing is clear: programmers love Kotlin. On the other hand, in the world of mobile application programming, Flutter has become the framework of choice. More developers are adopting Dart as their general-purpose language to build applications. But have you ever missed Kotlin when coding in Dart? Look no further! With kt.dart, you can have the best of both worlds.
Although there are some similarities between the two languages, the differences are numerous and significant. If you feel like Dart is missing something compared to Kotlin, kt.dart might be the missing puzzle piece you've been searching for.
Dart Like Kotlin?
From the basics of the GitHub repository, kt.dart is “a port of the Kotlin Standard Library for Dart/Flutter projects.” It’s a valuable extension to dart
and includes collections (like KtList, KtMap, KtSet) as well as other packages that can enhance any Dart/Flutter application.
The motivation behind its creation lies in certain limitations within Dart's core package. For instance, Dart lacks arrays; lists are used instead. Comparatively, Kotlin provides a rich standard library with high-level functions and consistent naming conventions. For business logic, Kotlin is a solid choice.
From creator Pascal Welsch’s explanation on high-level collections that Dart lacks:
"My job is to write business logic and SDKs with stable APIs. This is much more challenging in Dart compared to Kotlin. Particularly, Dart's collections aren’t ideal for that work. That’s why I’ve brought Kotlin’s high-level collections to Dart, allowing me to write better APIs."
This Project Offers:
- Immutable collections by default
- Consistent syntax
- Common methods
Written by Pascal Welsch under an Apache 2.0 license, you can read the README here.
Make sure to dive deeper into Pascal Welsch’s post on kt.dart. It’s an excellent read that explains some key points about what makes Kotlin libraries and immutable entities so desirable.
Before Getting Started
The package is available here; give it a spin.
Check out the kt_collection library to see all 150+ included methods.
As always, report any issues you encounter so that the creator can refine it further.
Looking for More?
As of now, kt.dart plans to add async, tuples, comparison, range, sequence, and text modules.
While we wait for more modules from kt.dart, here are a few other relevant projects we recommend to help you hit the bullseye. Happy coding!
- Kiwi: As delightful as it sounds. A simple, fast, and refreshing dependency injection library!
- Stagehand: A project generator for Dart applications, web apps, console apps, servers, and more.
- Hummingbird: A prototype of Flutter’s web platform. Keep an eye out for upcoming news and watch it take flight.
Recently, we asked our readers about which programming language would be relevant to them in 2019. The number one answer was none other than Dart. Clearly, it’s on point and showed massive growth over 2018. In this growing ecosystem, make sure to add this project to your list!
Let’s see what unfolds in the next 11 months. Will 2019 be Dart’s year?