filter method

  1. @useResult
KtList<T> filter(
  1. bool predicate(
    1. T
    )
)

Returns a list containing only elements matching the given predicate.

Implementation

@useResult
KtList<T> filter(bool Function(T) predicate) {
  final filtered = filterTo(mutableListOf<T>(), predicate);
  // TODO ping dart-lang/sdk team to check type bug
  // When in single line: type "DartMutableList<String>' is not a subtype of type 'Null"
  return filtered;
}