whereNotOnly method
Filters the list to exclude the specified keys for map elements.
keys is a list of keys to exclude.
Example:
final filteredList = list.whereNotOnly(["id", "createdAt"]);
Implementation
List<T> whereNotOnly(List<String> keys) {
if (isEmpty) {
return <T>[];
}
return whereType<Map<String, T>>()
.map((Map<String, T> element) {
return Map<String, T>.fromEntries(
element.entries.where((entry) => !keys.contains(entry.key)),
) as T;
})
.where((element) => (element as Map).isNotEmpty)
.toList();
}