KtListExtensions<T> extension

on

Properties

dart List<T>
Returns a read-only dart:core List [...]
read-only
lastIndex int
Returns the index of the last item in the list or -1 if the list is empty.
read-only

Methods

dropLast(int n) KtList<T>
Returns a list containing all elements except last n elements.
dropLastWhile(bool predicate(T)) KtList<T>
Returns a list containing all elements except last elements that satisfy the given predicate.
elementAt(int index) → T
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this list.
@nonNull
elementAtOrElse(int index, T defaultValue(int index)) → T
Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this list.
@nonNull
elementAtOrNull(int index) → T
Returns an element at the given index or null if the index is out of bounds of this collection.
@nullable
first([bool predicate(T)]) → T
Returns first element. [...]
@nonNull
foldRight<R>(R initial, R operation(T, R acc)) → R
Accumulates value starting with initial value and applying operation from right to left to each element and current accumulator value.
foldRightIndexed<R>(R initial, R operation(int index, T, R acc)) → R
Accumulates value starting with initial value and applying operation from right to left to each element with its index in the original list and current accumulator value. @param operation function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value.
getOrElse(int index, T defaultValue(int)) → T
Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this list.
@nonNull
getOrNull(int index) → T
Returns an element at the given index or null if the index is out of bounds of this list.
@nullable
last([bool predicate(T)]) → T
Returns the last element matching the given predicate. @throws NoSuchElementException if no such element is found.
@nonNull
reduceRight<S>(S operation(T, S acc)) → S
Accumulates value starting with last element and applying operation from right to left to each element and current accumulator value.
reduceRightIndexed<S>(S operation(int index, T, S acc)) → S
Accumulates value starting with last element and applying operation from right to left to each element with its index in the original list and current accumulator value. @param operation function that takes the index of an element, the element itself and current accumulator value, and calculates the next accumulator value.
single([bool predicate(T)]) → T
Returns the single element matching the given predicate, or throws an exception if the list is empty or has more than one element.
@nonNull
singleOrNull([bool predicate(T)]) → T
Returns the single element matching the given predicate, or null if element was not found or more than one element was found.
@nullable
slice(KtIterable<int> indices) KtList<T>
Returns a list containing elements at specified indices.
takeLast(int n) KtList<T>
Returns a list containing last n elements.
takeLastWhile(bool predicate(T)) KtList<T>
Returns a list containing last elements satisfying the given predicate.