mapNotNull<R> method

List<R> mapNotNull<R>(
  1. R? predicate(
    1. E
    )
)

Returns a list of all non-null items returned by applying predicate on the items of this list.

Implementation

List<R> mapNotNull<R>(R? Function(E) predicate) {
  final result = <R>[];
  for (final it in this) {
    final mapped = predicate(it);
    if (mapped != null) result.add(mapped);
  }
  return result;
}