intersection function

List intersection(
  1. List array,
  2. List values
)

Creates an array of unique values that are included in all given arrays The order and references of result values are determined by the first array.

Implementation

List intersection(List array, List values) {
  return array.where((element) => values.contains(element)).toList();
}