Skip to content
pubscout

kt_dart

1.1.0, released 4 years ago by pascalwelsch.com

Kotlin standard library port for Dart and Flutter with 150+ collection methods.

WASM-ready
$ flutter pub add kt_dart
Source repository

What it does

It brings Kotlin-style standard library collections like KtList, KtMap, and KtSet to Dart, providing immutable-by-default collections, deep equals comparisons, and 150+ functional methods.

AI-written summary of version 1.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You prefer Kotlin's collection API and want immutable collections by default
  • You need deep equals out-of-the-box for complex nested collections
  • You are porting Kotlin codebases or logic directly to Dart

Skip it when

  • You prefer sticking strictly to standard Dart core collections and syntax
  • You are sensitive to introducing third-party collection wrappers over native Lists and Maps

Strengths

  • Comprehensive port of Kotlin standard library with 150+ methods
  • Immutable collections by default preventing accidental mutations
  • Deep equals comparison out of the box

Weaknesses

  • Requires converting between native Dart collections and kt_dart collections
  • Collections do not directly implement standard Dart Iterable, requiring .iter or .asList

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1

Just add the dependency to pubspec.yaml and import 'package:kt_dart/kt.dart'.

import 'package:kt_dart/kt.dart';

void main() {
  final beatles = KtList.of("John", "Paul", "George", "Ringo");
  final partitions = beatles.partition((it) => it.contains("n"));
  print(partitions.first); // [John, Ringo]
}

Alternatives

Packages that do the same job and could replace kt_dart.

  • result_dart

    Kotlin and Swift inspired Result class for error handling in Dart and Flutter.

  • dartx

    Collection of useful static extension methods for Dart core types.

  • zxcvbn

    Dart port of Dropbox's zxcvbn password strength estimator library.

  • algorithmic

    A collection of searching, sorting, and string metric algorithms.