kotlin_dartpackage

kotlin.dart

This project is a port of Kotlins Kotlin Standard library for Dart/Flutter projects. It's a useful addition to dart:core and includes collections (KtList, KtMap, KtSet) as well as and other packages which can improve every Dart/Flutter app.

Motivation

Dart's dart:core package provides basic building blocks. But sometimes they are too low leven and not as straight-forward as Kotlins kotlin-stdlib.

Here are a few examples what this project offers: (click to expand)

Immutable collections by default

dart:core collections

Dart's List is mutable by default. The immutable List.unmodifiable is the same type but the mutation methods throw at runtime.

kotlin.dart collections

KtList and KtMutableList are two different Types. KtList is immutable by default and has no mutation methods (such as add). Methods like map((T)->R) or plusElement(T) return a new KtList leaving the old one unmodified.

dart:core collections

Dart's List works like a Array in Java. Equals doesn't compare the items, equals only checks the identity.
To compare the contents you have to use helper methods methods from 'package:collection/collection.dart'.

Some of Dart's method names feel unfamiliar. That's because modern languages and frameworks (Kotlin, Swift, TypeScript, ReactiveExtensions) kind of agreed on naming methods when it comes to collections. This makes it easy to switch platforms and discuss implementations with coworkers working with a different language.

Collection types, such as KtIterable, KtCollection, KtList, KtSet, KtMap with over 150 methods as well as related top-level functions.
The collections are immutable by default but offer a mutable counterpart i.e. KtMutableList.

Planned

License

Copyright 2019 Pascal Welsch
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.