whereIn method

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

Filters the list to include only elements where the specified key's value is in the given list.

key is the key to check. params is the list of values to match against.

Example:

final filteredList = list.whereIn("status", ["active", "pending"]);

Implementation

List<T> whereIn(String key, List<T> params) {
  if (isEmpty) {
    return <T>[];
  }
  return whereType<Map<T, T>>()
      .where((element) =>
          element.containsKey(key) && params.contains(element[key]))
      .map((e) => e as T)
      .toList();
}