filterIndexed method

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

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