|
| 1 | +## 0.7.0 |
| 2 | + |
| 3 | +The library has be upgrade to use [`Static Extension Methods`](https://github.com/dart-lang/language/issues/41). |
| 4 | + |
| 5 | +### Interop |
| 6 | + |
| 7 | +This update also includes extensions for Dart collections which allow easy interoperability between dart and kt.dart collections using the `.kt` and `.dart` getters. |
| 8 | + |
| 9 | +```dart |
| 10 | + // New: Converting dart collections to KtDart collections (mutable views) |
| 11 | + final KtMutableList<String> ktList = ["hey"].kt; |
| 12 | + final KtMutableSet<String> ktSet = {"hey"}.kt; |
| 13 | + final KtMutableMap<String, int> ktMap = {"hey": 1}.kt; |
| 14 | +
|
| 15 | + // Converting KtDart collections to dart collections |
| 16 | + final List<String> dartList = KtList.of("hey").dart; |
| 17 | + final Set<String> dartSet = KtSet.of("hey").dart; |
| 18 | + final Map<String, int> dartMap = KtMap.from({"hey": 1}).dart; |
| 19 | +``` |
| 20 | + |
| 21 | +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. |
| 22 | + |
| 23 | +To convert dart collections to their immutable kt.dart counterparts use: `.toImmutableList()`, `.toImmutableSet()`, `.toImmutableMap()` |
| 24 | + |
| 25 | +```dart |
| 26 | + // New: Make dart collections immutable |
| 27 | + final KtList<String> list = ["hey"].toImmutableList(); |
| 28 | + final KtSet<String> set = {"hey"}.toImmutableSet(); |
| 29 | + final KtMap<String, int> map = {"hey": 1}.toImmutableMap(); |
| 30 | +``` |
| 31 | + |
| 32 | +### Possible breaking changes |
| 33 | + |
| 34 | +- Relax `sortBy`/`sortByDescending`, `maxBy`/`minBy` typing to work better with ints and doubles [#116](https://github.com/passsy/kt.dart/pull/116) |
| 35 | +```dart |
| 36 | +// Was: int doesn't not implement Comparable<int> but Comparable<num> |
| 37 | +// minBy therefore required some help to figure out the correct type (<num>) |
| 38 | +users.minBy<num>((it) => it.age); |
| 39 | +
|
| 40 | +// Now: minBy doesn't require the Comparable (num) to have the same same as the value (int). |
| 41 | +users.minBy((it) => it.age); |
| 42 | +``` |
| 43 | +- Remove unnecessary generic `R` from `KtIterable.zipWithNext` [#118](https://github.com/passsy/kt.dart/pull/118) |
| 44 | + |
| 45 | +### New Extensions |
| 46 | +- `KtPair` and `KtTriple` now have a new `toList()` function to convert the values to a `KtList` |
| 47 | +- `KtList?.orEmpty()` returns an empty list when the list is `null` |
| 48 | +- `KtSet?.orEmpty()` returns an empty set when the set is `null` |
| 49 | +- `KtMap?.orEmpty()` returns an empty map when the map is `null` |
| 50 | +- `KtMap.ifEmpty(() -> defaultValue)` returns the default value when the map is empty |
| 51 | +- `KtIterable<KtIterable<T>>.flatten()` flattens the nested collections to `KtIterable<T>` |
| 52 | +- `KtIterable<KtPair<T, U>>.unzip(): KtPair<KtList<T>, KtList<U>>` unzips list of pairs to list of their first and second values |
| 53 | +- `KtIterable<Comparable<T>>.min()` returns the smallest element of any comparable iterable |
| 54 | +- `KtIterable<Comparable<T>>.max()` returns the largest element of any comparable iterable |
| 55 | + |
| 56 | + |
1 | 57 | ## 0.7.0-dev.4 |
2 | 58 |
|
3 | 59 | - New extension `Iterable.toImmutableList(): KtList` |
|
0 commit comments