Skip to content

Commit dcdad81

Browse files
committed
* formatting
1 parent d204215 commit dcdad81

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

packages/netglade_utils/lib/src/extensions/iterable_extensions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension IterableExtensions<T> on Iterable<T> {
1111
}
1212

1313
/// Returns a list containing only elements from the given collection having distinct keys returned by the given [selector] function. If multiple elements have the same key, first element is returned.
14-
Iterable<T> distinctBy<K>(Selector<T,K> selector) {
14+
Iterable<T> distinctBy<K>(Selector<T, K> selector) {
1515
return groupBy<T, K>(this, selector)
1616
.values
1717
// ignore: avoid-unsafe-collection-methods, groupBy returns non-empty lists

packages/netglade_utils/test/src/extensions/iterable_extensions_test.dart

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,37 @@ void main() {
1818

1919
group('distinct by', () {
2020
test('distinct', () {
21-
expect([[1,3], [2,5], [3,3]].distinctBy((e) => e.firstOrNull), equals({[1,3], [2,5], [3,3]}));
21+
expect(
22+
[
23+
[1, 3],
24+
[2, 5],
25+
[3, 3],
26+
].distinctBy((e) => e.firstOrNull),
27+
equals({
28+
[1, 3],
29+
[2, 5],
30+
[3, 3],
31+
}),
32+
);
2233
});
2334

2435
test('with duplicates', () {
25-
expect([[1,3], [2,5], [1,6], [1,0]].distinctBy((e) => e.firstOrNull), equals({[1,3], [2,5]}));
36+
expect(
37+
[
38+
[1, 3],
39+
[2, 5],
40+
[1, 6],
41+
[1, 0],
42+
].distinctBy((e) => e.firstOrNull),
43+
equals({
44+
[1, 3],
45+
[2, 5],
46+
}),
47+
);
2648
});
2749

2850
test('empty', () {
29-
expect(<int>[].distinctBy((e) => e*e), equals(<int>{}));
51+
expect(<int>[].distinctBy((e) => e * e), equals(<int>{}));
3052
});
3153
});
3254
}

0 commit comments

Comments
 (0)