intersection method

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

Returns elements that appear in both this list and other.

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

Implementation

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