whereIn method

List<T> whereIn(
  1. String key,
  2. List<num> params
)

Removes elements from the list that do not have a specified item value

that is not contained within the given list

Example:

list.whereIn("key", [value1, value2])

Implementation

List<T> whereIn(String key, List<num> params) {
  if (isEmpty) {
    return <T>[];
  }
  final List<T> result = <T>[];

  for (final num param in params) {
    for (final T element in this) {
      if (element is Map<T, T> &&
          element.containsKey(key) &&
          element[key] == param) {
        result.add(element);
      }
    }
  }

  return result;
}