partition method

Pair<List<T>, List<T>> partition(
  1. bool predicate(
    1. T
    )
)

Splits the list into a Pair based on predicate. First list: elements where predicate is true. Second list: elements where predicate is false.

Implementation

Pair<List<T>, List<T>> partition(bool Function(T) predicate) {
  final yes = <T>[], no = <T>[];
  for (final e in this) {
    (predicate(e) ? yes : no).add(e);
  }
  return Pair(yes, no);
}