PackageTrack
Sign in Get early access

kt_dart

This project is a port of kotlin-stdlib for Dart/Flutter projects. It includes collections (KtList, KtMap, KtSet) with 150+ methods as well as other useful packages.

1.1.0 6.7K downloads/mo #3467 most downloaded on pub.dev passsy/kt.dart

What this package is like to depend on

Last release 3 years ago

no release in 18 months

Ships fairly regularly

a new release about every 4 months

Nearly every release is documented

notes for 12 of 12 stable releases

Nothing withdrawn

no release was ever pulled

8 years old

18 releases · first in 2019

0 releases in the last 12 months

see the full history below

Release timeline

18 releases · Jan 2019 to Mar 2023
2020 2021 2022 2023 2024 2025 2026
Release Pre-release

Releases

latest 18
  1. 1.1.0 20 Mar 2023
    Release notes
    • #190 KtMutableMapEntry.setValue() is now implemented (thx @hugobrancowb)
    • #188 Added KtIterable.firstNotNullOf() KtIterable.firstNotNullOfOrNull() (thx @hugobrancowb)
    • #196 Methods, returning mutated copies are now marked with @useReslt (thx @nohli)
    • #197 mapNotNull, mapNotNullTo, mapIndexedNotNull, mapIndexedNotNullTo, filterNotNullTo work now correctly for non-nullable types
    Open source →
    Release notes
    • #190 KtMutableMapEntry.setValue() is now implemented (thx @hugobrancowb)
    • #188 Added KtIterable.firstNotNullOf() KtIterable.firstNotNullOfOrNull() (thx @hugobrancowb)
    • #196 Methods, returning mutated copies are now marked with @useReslt (thx @nohli)
    • #197 mapNotNull, mapNotNullTo, mapIndexedNotNull, mapIndexedNotNullTo, filterNotNullTo work now correctly for non-nullable types
    Open source →
  2. 1.0.0 27 Sep 2022
    Release notes
    • #183 New: KtIterable.sumOf thx @nohli
    • Update dependencies and guarantee compatibility with Dart 2.12-2.18

    Full Changelog: v0.10.0...v1.0.0

    Open source →
    Release notes
    • #183 New: KtIterable.sumOf thx @nohli
    • Update dependencies and guarantee compatibility with Dart 2.12-2.18
    Open source →
  3. 0.10.0 31 Oct 2021
    Release notes

    Some nullsafety improvements, type fixes and a lot of new Kotlin 1.4 extensions

    • #141 Fix: requireNoNulls() now converts T? to T

    • 1df6e1a Fix: .dart and .iter on Iterable<T> now work for all types not only if T implements Comparable

    • f43cbc5 Fix: *NotNull methods now return non-nullable types

    • b727893 Fix: The hashcode of all collections doesn't get cached anymore. That caused problems when mutable items in a KtList changed. The equals and hashCode methods now always change together.

    • #141 Improve: KtIterable.onEach can now be chained

    • #141 New: KtIterable.cast() to manually cast values

    • #141 New: KtIterable.onEachIndexed

    • #163 New: KtIterable.shuffled()

    • #166 New: KtIterable.reduceOrNull()

    • #169 New: KtMutableList.removeFirst() KtMutableList.removeLast()

    • #173 New: KtMutableList.removeFirstOrNull() KtMutableList.removeLastOrNull()

    • #171 New: KtIterable.minOf()

    • #165 New: String.replaceFirstChar()

    • #170 New: KtIterable.minOrNull(), KtIterable.maxOrNull(), deprecates KtIterable.min(), KtIterable.max(),

    • #174 New: KtIterable.runningReduce()

    • #177 New: KtCollection.randomOrNull()

    • #178 New: KtIterable.flatMapIndexed, KtIterable.flatMapIndexedTo

    Thanks to the #hacktoberfest contributors @Anas35, @robiness, @MatthaiosSait, @Dev-dfm, @marciokuroki, @Rishabh-Negi

    Open source →
    Release notes

    Some nullsafety improvements, type fixes and a lot of new Kotlin 1.4 extensions

    • #141 Fix: requireNoNulls() now converts T? to T

    • 1df6e1a Fix: .dart and .iter on Iterable<T> now work for all types not only if T implements Comparable

    • f43cbc5 Fix: *NotNull methods now return non-nullable types

    • b727893 Fix: The hashcode of all collections doesn't get cached anymore. That caused problems when mutable items in a KtList changed. The equals and hashCode methods now always change together.

    • #142 Improve: KtIterable.onEach can now be chained

    • #141 New: KtIterable.cast() to manually cast values

    • #142 New: KtIterable.onEachIndexed

    • #163 New: KtIterable.shuffled()

    • #166 New: KtIterable.reduceOrNull()

    • #169 New: KtMutableList.removeFirst() KtMutableList.removeLast()

    • #173 New: KtMutableList.removeFirstOrNull() KtMutableList.removeLastOrNull()

    • #171 New: KtIterable.minOf()

    • #165 New: String.replaceFirstChar()

    • #170 New: KtIterable.minOrNull(), KtIterable.maxOrNull(), deprecates KtIterable.min(), KtIterable.max(),

    • #174 New: KtIterable.runningReduce()

    • #177 New: KtCollection.randomOrNull()

    • #178 New: KtIterable.flatMapIndexed, KtIterable.flatMapIndexedTo

    Thanks to the #hacktoberfest contributors @Anas35, @robiness, @MatthaiosSait, @Dev-dfm, @marciokuroki, @Rishabh-Negi

    Open source →
  4. 0.9.1 22 May 2021
    Release notes
    • #138 Deprecate KtIterable<T>.sumByDouble in favor of KtIterable<T>.sumBy which now works for int and double
    • #140 KtMap.getOrDefault now returns V instead of V?
    • #140 Fix KtMap.groupBy returning KtMap<K, KtMutableList<T>> instead of KtMap<K, KtList<T>> causing generic type problems in further processing
    Open source →
    Release notes
    • #138 Deprecate KtIterable<T>.sumByDouble in favor of KtIterable<T>.sumBy which now works for int and double
    • #140 KtMap.getOrDefault now returns V instead of V?
    • #140 Fix KtMap.groupBy returning KtMap<K, KtMutableList<T>> instead of KtMap<K, KtList<T>> causing generic type problems in further processing
    Open source →
  5. 0.9.0 14 Mar 2021
    Release notes
    • stable dependencies
    • Improve KtSet.contains performance
    Open source →
    Release notes
    • stable dependencies
    • Improve KtSet.contains performance
    Open source →
  6. 0.9.0-nullsafety.0 19 Nov 2020 pre-release
    Release notes
    • Migrate to Dart 2.12 with [null-safety(https://dart.dev/null-safety) support
    Open source →
    Release notes
    • Migrate to Dart 2.12 with [null-safety(https://dart.dev/null-safety) support
    Open source →
  7. 0.8.0 01 Oct 2020
    Release notes

    New package:kt_dart/standard.dart library containing Kotlins loved standard extensions

    • #120 Standard extensions let, also, takeIf and takeUnless
    • #120 TODO([String message]) top-level function which throws NotImplementedException
    • #120 repeat(int times, void Function(int) action) top-level function

    More cool updates

    • #124 KtList.of and KtSet.of now allow null as parameters. Same for listOf and setOf
    • #131 Chain Comparators with the new thenBy and thenByDescending functions.
    • #126 Allow const .empty() constructors for KtList, KtMap and KtSet (Thanks @TimWhiting)
    • #127 plus, minus operator overrides for KtSet, returning KtSet and not KtList as the KtIterable operators do
    Open source →
    Release notes

    New package:kt_dart/standard.dart library containing Kotlins loved standard extensions

    • #120 Standard extensions let, also, takeIf and takeUnless
    • #120 TODO([String message]) top-level function which throws NotImplementedException
    • #120 repeat(int times, void Function(int) action) top-level function

    More cool updates

    • #124 KtList.of and KtSet.of now allow null as parameters. Same for listOf and setOf
    • #131 Chain Comparators with the new thenBy and thenByDescending functions.
    • #126 Allow const .empty() constructors for KtList, KtMap and KtSet (Thanks @TimWhiting)
    • #127 plus, minus operator overrides for KtSet, returning KtSet and not KtList as the KtIterable operators do
    Open source →
  8. 0.8.0-dev.1 27 Apr 2020 pre-release
    Release notes
    • #124 KtList.of and KtSet.of now allow null as parameters. Same for listOf and setOf
    • #120 Standard extensions let, also, takeIf and takeUnless
    • #120 TODO([String message]) top-level function which throws NotImplementedException
    • #120 repeat(int times, void Function(int) action) top-level function
    • #126 Allow const .empty() constructors for KtList, KtMap and KtSet (Thanks @TimWhiting)
    • #127 plus, minus operator overrides for KtSet, returning KtSet and not KtList as the KtIterable operators do
    Open source →
    Release notes
    • #124 KtList.of and KtSet.of now allow null as parameters. Same for listOf and setOf
    • #120 Standard extensions let, also, takeIf and takeUnless
    • #120 TODO([String message]) top-level function which throws NotImplementedException
    • #120 repeat(int times, void Function(int) action) top-level function
    • #126 Allow const .empty() constructors for KtList, KtMap and KtSet (Thanks @TimWhiting)
    • #127 plus, minus operator overrides for KtSet, returning KtSet and not KtList as the KtIterable operators do
    Open source →
  9. 0.7.0 01 Mar 2020
    Release notes

    The library has be upgrade to use Static Extension Methods.

    Interop

    This update also includes extensions for Dart collections which allow easy interoperability between dart and kt.dart collections using the .kt and .dart getters.

      // New: Converting dart collections to KtDart collections (mutable views)
      final KtMutableList<String> ktList = ["hey"].kt;
      final KtMutableSet<String> ktSet = {"hey"}.kt;
      final KtMutableMap<String, int> ktMap = {"hey": 1}.kt;
    
      // Converting KtDart collections to dart collections
      final List<String> dartList = KtList.of("hey").dart;
      final Set<String> dartSet = KtSet.of("hey").dart;
      final Map<String, int> dartMap = KtMap.from({"hey": 1}).dart;

    Note: ["Hello", "World"].kt returns a KtMutableList<String> and mutations are reflected on the original dart list. It is not a copy! Because it doesn't copy it is very cheap and only syntax sugar.

    To convert dart collections to their immutable kt.dart counterparts use: .toImmutableList(), .toImmutableSet(), .toImmutableMap()

      // New: Make dart collections immutable
      final KtList<String> list = ["hey"].toImmutableList();
      final KtSet<String> set = {"hey"}.toImmutableSet();
      final KtMap<String, int> map = {"hey": 1}.toImmutableMap();

    Possible breaking changes

    • Relax sortBy/sortByDescending, maxBy/minBy typing to work better with ints and doubles #116
    // Was: int doesn't not implement Comparable<int> but Comparable<num>
    // minBy therefore required some help to figure out the correct type (<num>) 
    users.minBy<num>((it) => it.age);
    
    // Now: minBy doesn't require the Comparable (num) to have the same same as the value (int).
    users.minBy((it) => it.age);
    • Remove unnecessary generic R from KtIterable.zipWithNext #118

    New Extensions

    • KtPair and KtTriple now have a new toList() function to convert the values to a KtList
    • KtList?.orEmpty() returns an empty list when the list is null
    • KtSet?.orEmpty() returns an empty set when the set is null
    • KtMap?.orEmpty() returns an empty map when the map is null
    • KtMap.ifEmpty(() -> defaultValue) returns the default value when the map is empty
    • KtIterable<KtIterable<T>>.flatten() flattens the nested collections to KtIterable<T>
    • KtIterable<KtPair<T, U>>.unzip(): KtPair<KtList<T>, KtList<U>> unzips list of pairs to list of their first and second values
    • KtIterable<Comparable<T>>.min() returns the smallest element of any comparable iterable
    • KtIterable<Comparable<T>>.max() returns the largest element of any comparable iterable
    Open source →
    Release notes

    The library has be upgrade to use Static Extension Methods.

    Interop

    This update also includes extensions for Dart collections which allow easy interoperability between dart and kt.dart collections using the .kt and .dart getters.

      // New: Converting dart collections to KtDart collections (mutable views)
      final KtMutableList<String> ktList = ["hey"].kt;
      final KtMutableSet<String> ktSet = {"hey"}.kt;
      final KtMutableMap<String, int> ktMap = {"hey": 1}.kt;
    
      // Converting KtDart collections to dart collections
      final List<String> dartList = KtList.of("hey").dart;
      final Set<String> dartSet = KtSet.of("hey").dart;
      final Map<String, int> dartMap = KtMap.from({"hey": 1}).dart;
    

    Note: ["Hello", "World"].kt returns a KtMutableList<String> and mutations are reflected on the original dart list. It is not a copy! Because it doesn't copy it is very cheap and only syntax sugar.

    To convert dart collections to their immutable kt.dart counterparts use: .toImmutableList(), .toImmutableSet(), .toImmutableMap()

      // New: Make dart collections immutable
      final KtList<String> list = ["hey"].toImmutableList();
      final KtSet<String> set = {"hey"}.toImmutableSet();
      final KtMap<String, int> map = {"hey": 1}.toImmutableMap();
    

    Possible breaking changes

    • Relax sortBy/sortByDescending, maxBy/minBy typing to work better with ints and doubles #116
    // Was: int doesn't not implement Comparable<int> but Comparable<num>
    // minBy therefore required some help to figure out the correct type (<num>) 
    users.minBy<num>((it) => it.age);
    
    // Now: minBy doesn't require the Comparable (num) to have the same same as the value (int).
    users.minBy((it) => it.age);
    
    • Remove unnecessary generic R from KtIterable.zipWithNext #118

    New Extensions

    • KtPair and KtTriple now have a new toList() function to convert the values to a KtList
    • KtList?.orEmpty() returns an empty list when the list is null
    • KtSet?.orEmpty() returns an empty set when the set is null
    • KtMap?.orEmpty() returns an empty map when the map is null
    • KtMap.ifEmpty(() -> defaultValue) returns the default value when the map is empty
    • KtIterable<KtIterable<T>>.flatten() flattens the nested collections to KtIterable<T>
    • KtIterable<KtPair<T, U>>.unzip(): KtPair<KtList<T>, KtList<U>> unzips list of pairs to list of their first and second values
    • KtIterable<Comparable<T>>.min() returns the smallest element of any comparable iterable
    • KtIterable<Comparable<T>>.max() returns the largest element of any comparable iterable
    Open source →
  10. 0.7.0+1 01 Mar 2020
    Release notes
    • Fix unused import
    Open source →
  11. 0.7.0-dev.4 29 Dec 2019 pre-release
    Release notes
    • New extension Iterable.toImmutableList(): KtList
    • New extension Iterable.toImmutableSet(): KtSet
    • New extension KtIterable<num>.average(): double
    • Relax sortBy/sortByDescending, maxBy/minBy typing to work better with ints and doubles
    // Was: int doesn't not implement Comparable<int> but Comparable<num>
    // minBy therefore required some help to figure out the correct type (<num>) 
    users.minBy<num>((it) => it.age);
    
    // Now: minBy doesn't require the Comparable (num) to have the same same as the value (int).
    users.minBy((it) => it.age);
    Open source →
    Release notes
    • New extension Iterable.toImmutableList(): KtList
    • New extension Iterable.toImmutableSet(): KtSet
    • New extension KtIterable<num>.average(): double
    • Relax sortBy/sortByDescending, maxBy/minBy typing to work better with ints and doubles
    // Was: int doesn't not implement Comparable<int> but Comparable<num>
    // minBy therefore required some help to figure out the correct type (<num>) 
    users.minBy<num>((it) => it.age);
    
    // Now: minBy doesn't require the Comparable (num) to have the same same as the value (int).
    users.minBy((it) => it.age);
    
    Open source →
  12. 0.7.0-dev.3 22 Dec 2019 pre-release
    Release notes
    • Rename (List|Set|Map).immutable() extension to .toImmutableList() to match Dart SDK naming schema.
    • Remove int.rangeTo(X) extension. Please use the dartx as replacement which offers the same extension
    • Remove T.to(X) extension to create a KtPair. It's too general and should be offered by the dart SDK not a 3rd party package
    Open source →
  13. 0.7.0-dev.2 21 Oct 2019 pre-release
    Release notes

    New .dart extensions to convert KtDart collections back to dart collections.

      // New: Converting dart collections to KtDart collections (mutable views)
      final KtMutableList<String> ktList = ["hey"].kt;
      final KtMutableSet<String> ktSet = {"hey"}.kt;
      final KtMutableMap<String, int> ktMap = {"hey": 1}.kt;
    
      // Converting KtDart collections to dart collections
      final List<String> dartList = KtList.of("hey").dart;
      final Set<String> dartSet = KtSet.of("hey").dart;
      final Map<String, int> dartMap = KtMap.from({"hey": 1}).dart;
    
    Open source →
  14. 0.7.0-dev.1 21 Oct 2019 pre-release
    Release notes

    KtDart makes full use of darts static extension methods, introduced with Dart 2.6.

    The public API stays unchanged and is backwards compatible.

    Improved interopt with dart collections

    It is now easier then ever to convert dart to ktdart collections and vice versa. Use the .kt property to convert dart collections to KtDart collections. (Note: .kt create a view, which allows you to mutate the original dart collection).

      // New: Make dart collections immutable
      final KtList<String> list = ["hey"].immutable();
      final KtSet<String> set = {"hey"}.immutable();
      final KtMap<String, int> map = {"hey": 1}.immutable();
    
      // New: Converting dart collections to KtDart collections (mutable views)
      final KtMutableList<String> ktList = ["hey"].kt;
      final KtMutableSet<String> ktSet = {"hey"}.kt;
      final KtMutableMap<String, int> ktMap = {"hey": 1}.kt;
    
      // Converting KtDart collections to dart collections
      final List<String> dartList = KtList.of("hey").asList();
      final Set<String> dartSet = KtSet.of("hey").asSet();
      final Map<String, int> dartMap = KtMap.from({"hey": 1}).asMap();
    

    Tuple improvements

    KtPairs can now created with the T0.to(T1) extension.

    final KtPair<String, int> pair = "foo".to(42);
    

    Also, KtPair and KtTriple now have a new toList() function to convert the values to a KtList.

    New Extensions

    • KtList?.orEmpty() returns an empty list when the list is null
    • KtSet?.orEmpty() returns an empty set when the set is null
    • KtMap?.orEmpty() returns an empty map when the map is null
    • KtMap.ifEmpty(() -> defaultValue) returns the default value when the map is empty
    • KtIterable<KtIterable<T>>.flatten() flattens the nested collections to KtIterable<T>
    • KtIterable<KtPair<T, U>>.unzip(): KtPair<KtList<T>, KtList<U>> unzips list of pairs to list of their first and second values
    • KtIterable<Comparable<T>>.min() returns the smallest element of any comparable iterable
    • KtIterable<Comparable<T>>.max() returns the largest element of any comparable iterable
    Open source →
  15. 0.6.2 24 Apr 2019
    Release notes

    diff v0.6.1...v0.6.2

    • #96 Dart 2.0.0 comparability. (Was only Dart 2.1.0 compatible).
    • #97 Fix broken links to lib classes in documentation
    • #97 Adjust analyzer rules. Add new ones and explain why others aren't active. Adjusted the code accordingly
    Open source →
  16. 0.6.1 27 Mar 2019
    Release notes

    diff v0.6.0...v0.6.1

    • #92 Improve pub score by changing comments to ///
    Open source →
  17. 0.6.0 27 Mar 2019
    Release notes

    diff v0.5.0...v0.6.0

    This major update of kt.dart add 10+ extension methods for KtMap and makes working with maps even easier.

    Behavior Changes

    The properties KtList.list: List,KtSet.set: Set are now deprecated and KtMap.map: Map was removed. Those properties where used to convert kt.dart collections to dart collections. Instead use the new KtList.asList(): List, KtSet.asSet(): Set, KtMa.asMap(): Map methods. The old properties returned copies of the collections. The new as-methods return views of the original collections and reflect changes of the original data.

    This breaking change was necessary because the property KtMap.map: Map<K, V> was conflicting with KtMap.map(MapEntry<K, V> -> R) : KtList<R> to map the entries to items of a KtList. Read about further details here.

    If you have used properties to iterate over the collections using a for-loop you should now always use iter which is available for all kt.dart collections.

    for (final element in listOf("a", "b", "c").iter) {
      print(element); 
    }
    for (final element in setOf("a", "b", "c").iter) {
      print(element); 
    }
    for (final p in mapFrom({1: "Bulbasaur", 2: "Ivysaur"}).iter) {
      print("${p.key} -> ${p.value}"); 
    }
    

    Additions

    • #86 New: KtMap.map Returns a list containing the results of applying the given transform function to each entry in the original map.
    • #86 New: KtMap.iter Access to a Iterable to be used in for-loops
    • #87 New: KtMap.count Returns the number of entries matching the given [predicate] or the number of entries when predicate = null.
    • #89 New: KtMap.minBy Returns the first entry yielding the smallest value of the given function or null if there are no entries.
    • #89 New: KtMap.minWith Returns the first entry having the smallest value according to the provided comparator or null if there are no entries.
    • #89 New: KtMap.maxBy Returns the first entry yielding the largest value of the given function or null if there are no entries.
    • #89 New: KtMap.maxWith Returns the first entry having the largest value according to the provided comparator or null if there are no entries.
    • #90 New: KtMap.toList Returns a KtList containing all key-value pairs.
    • #78 New: KtMap.forEach Performs given action on each key/value pair from this map. thanks @acherkashyn
    • #80 New: KtMap.none Returns true if there is no entries in the map that match the given predicate. thanks @acherkashyn
    • #80 New: KtMap.all Returns true if all entries match the given predicate. thanks @acherkashyn
    • #80 New: KtMap.any Returns true if there is at least one entry that matches the given predicate. thanks @acherkashyn
    • #84 New: KtMap.filterKeys Returns a map containing all key-value pairs with keys matching the given predicate.
    • #84 New: KtMap.filterValues Returns a map containing all key-value pairs with values matching the given predicate.
    • #79 New: KtMap.asMap Returns a read-only dart:core Map
    • #79 New: KtMutableMap.asMap Creates a Map instance that wraps the original KtMap. It acts as a view.

    • #75 New: KtIterable.takeWhile Returns a list containing first elements satisfying the given predicate.
    • #76 New: KtIterable.takeLastWhile Returns a list containing last elements satisfying the given predicate.

    • #73 New: KtList.takeLast, Returns a list containing last n elements.
    • #79 New: KtList.asList Returns a read-only dart:core List
    • #79 New: KtMutableList.asList Creates a List instance that wraps the original KtList. It acts as a view.

    • #79, #91 New: KtSet.asSet Returns a read-only dart:core Set
    • #79 New: KtMutableSet.asSet Creates a Set instance that wraps the original KtSet. It acts as a view.

    Bugfixes

    • #74 Fix: KtList.dropLastWhile was off by 1
    • #88 Fix: KtIterable.minWith returned the max value

    Documentation

    • #68 Document KtSet constructors
    • #70 Fix README typos, thanks @RedBrogdon

    Misc.

    • #69 KtMutableListIterator throws IndexOutOfBoundsException when calling set before next was called
    • #81 Force dartfmt on CI
    • #83 Improve .gitignore
    Open source →
  18. 0.5.0 11 Jan 2019
    Release notes

    diff v0.4.2...v0.5.0

    Project has been renamed to kt.dart. If you're using a previous version upgrade like this:

    pubspec.yaml

    dependencies:
    -  dart_kollection: ^0.3.0
    -  kotlin_dart: ^0.4.0
    +  kt_dart: ^0.5.0
    

    your_source.dart

    - import 'package:dart_kollection/dart_kollection.dart';
    - import 'package:kotlin_dart/kotlin.dart';
    + import 'package:kt_dart/kt.dart';
    
    • #66 Rename KPair -> KtPair and KTriple -> KtTriple
    • #67 Rename package kotlin_dart -> kt_dart
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive