list_ext 0.1.11
list_ext: ^0.1.11 copied to clipboard
Dart extension methods for Iterable and List. You can easily sum, count elements and many more.
example/main.dart
import 'package:list_ext/list_ext.dart';
class Foo {
final int bar;
const Foo(this.bar);
}
void main() {
final list = [Foo(1), Foo(2), Foo(3), Foo(2)];
final contains2 = list.countWhere((element) => element.bar == 2);
final contains4 = list.countWhere((element) => element.bar == 4);
print('Count of foo with bar = 2: $contains2');
print('Count of foo with bar = 4: $contains4');
// > Contains foo with bar = 2: true
// > Contains foo with bar = 4: false
}