difference method

List<T> difference(
  1. List<T> other
)

Returns elements in this list that are NOT in other.

[1, 2, 3, 4].difference([2, 4]) // [1, 3]

Implementation

List<T> difference(List<T> other) {
  final otherSet = other.toSet();
  return where((e) => !otherSet.contains(e)).toList();
}