filterIndexed method

  1. @useResult
KtList<T> filterIndexed(
  1. bool predicate(
    1. int index,
    2. T
    )
)

Returns a list containing only elements matching the given predicate. @param predicate function that takes the index of an element and the element itself and returns the result of predicate evaluation on the element.

Implementation

@useResult
KtList<T> filterIndexed(bool Function(int index, T) predicate) {
  final filtered = filterIndexedTo(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;
}