partition method
Partitions this iterable into two lists: elements that satisfy test
and those that do not.
[1, 2, 3, 4, 5].partition((e) => e.isOdd);
// ([1, 3, 5], [2, 4])
Implementation
(List<T>, List<T>) partition(bool Function(T) test) {
final passed = <T>[];
final failed = <T>[];
for (final element in this) {
if (test(element)) {
passed.add(element);
} else {
failed.add(element);
}
}
return (passed, failed);
}