whereNotIn method

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

Filters the list to exclude 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.whereNotIn("status", ["inactive", "deleted"]);

Implementation

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