void retainWhere(String path, bool test(element))

Removes all objects from the list at path that fail to satisfy test.

Source

void retainWhere(String path, bool test(element)) {
  removeWhere(path, (element) => !test(element));
}