listSubtractAll<T> function

List<T> listSubtractAll<T>(
  1. Iterable<T> original,
  2. Iterable<T> sublist
)

Subtract all elements that are in sublist

Implementation

List<T> listSubtractAll<T>(Iterable<T> original, Iterable<T> sublist) {
  if (original.isEmpty) {
    return [];
  }
  List<T> result = List.from(original);

  for (T v in listNub(sublist)) {
    result.removeWhere((element) => deepEquals(element, v));
  }

  return result;
}