takeIf method
Take if f
is true.
Returns a new list with the elements taken if f
is true.
Implementation
List<T> takeIf(bool Function(T) f) {
final list = <T>[];
for (final item in this) {
if (f(item)) {
list.add(item);
}
}
return list;
}