divideIn2 method
Divides the list into two.
The first one contains all items which satisfy the provided test
.
The last one contains all the other items.
The relative order of the items will be maintained.
See also: IListOf2
Implementation
IListOf2<IList<T>> divideIn2(bool Function(T item) test) {
List<T> first = [];
List<T> last = [];
for (T item in this) {
if (test(item))
first.add(item);
else
last.add(item);
}
return IListOf2(
IList._unsafeFromList(first, config: config),
IList._unsafeFromList(last, config: config),
);
}