0.7.0-dev.1
Pre-release
Pre-release
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
KtPair
s 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 isnull
KtSet?.orEmpty()
returns an empty set when the set isnull
KtMap?.orEmpty()
returns an empty map when the map isnull
KtMap.ifEmpty(() -> defaultValue)
returns the default value when the map is emptyKtIterable<KtIterable<T>>.flatten()
flattens the nested collections toKtIterable<T>
KtIterable<KtPair<T, U>>.unzip(): KtPair<KtList<T>, KtList<U>>
unzips list of pairs to list of their first and second valuesKtIterable<Comparable<T>>.min()
returns the smallest element of any comparable iterableKtIterable<Comparable<T>>.max()
returns the largest element of any comparable iterable
Upgrade
dependencies:
kt_dart: ^0.7.0-dev.1