mapIndexedNotNull<R> method

  1. @useResult
KtList<R> mapIndexedNotNull<R>(
  1. R? transform(
    1. int index,
    2. T
    )
)

Returns a list containing only the non-null results of applying the given transform function to each element and its index in the original collection. @param transform function that takes the index of an element and the element itself and returns the result of the transform applied to the element.

Implementation

@useResult
KtList<R> mapIndexedNotNull<R>(R? Function(int index, T) transform) {
  final mapped = mapIndexedNotNullTo(mutableListOf<R>(), transform);
  // 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 mapped;
}