No matter how great Flutter is, using Dart feels like a step backwards when coming from Kotlin. I understand the reasoning why Dart was chosen as Flutters language but I miss Kotlins feature rich standard library. That’s why I decided to port it to Dart. Welcome kt.dart!

kt.dart doesn’t introduce new language features but it would definitely benefit from some. That’s why I invite you to upvote some of my favorites Dart language proposals: Extension Methods, Optional Semicolons, Non-Nullable types, Destructuring Declarations, Data Classes

Dart’s missing high-level collections for business logic

The most common collection in nearly every programming language is the array. Dart doesn’t have arrays, Dart arrays are Lists. And Dart’s Lists are amazing compared to Java’s Array . But is such a comparison justifiable? Shouldn’t Dart’s List better be compared with Java’s ArrayList or Kotlins MutableList ?

Neither of those comparisons are fair. The most important aspect is that there is a right tool for the job.

My job is to write business logic and SDK with stable APIs. This is much more challenging in Dart compared to Kotlin. Especially Dart’s collections aren’t perfect for the job. That’s why I ported Kotlins high-level collections to Dart, allow me to write better APIs.

Before I jump into kt.dart s API, I’d like to show where Dart’s collections are lacking compared to kotlins collections:

Explicit immutability

Using Kotlin made me used to immutability. My entities are immutable (data classes) and so are the Lists I return from my APIs. Immutable entities aren’t a problem in Dart. But a immutable List has the same API as a modifiable List . Consumers might expect to be able to mutate a immutable List . There is no compiler warning, it crashes at runtime.

There is also no way to test if a List is modifiable or not. Unlike Kotlin, Dart doesn’t differentiate between List and MutableList .

Deep Equality

Comparing two Dart collections ( List , Set or Map ) doesn’t compare their contents, it only checks their identity. Dart offers a solution: The equality functions in the collection package.