filter method

List<T> filter(
  1. bool test(
    1. T element
    )
)

Returns a list containing only elements matching the given predicate!

Implementation

List<T> filter(bool test(T element)) {
  if (this == null) return <T>[];
  final result = <T>[];
  this!.forEach((e) {
    if (test(e)) {
      result.add(e);
    }
  });
  return result;
}