IterableExtension<T> extension

on Iterable<T>

*<Null safety>*

Properties

firstOrNull → T?

The first element, or null if the iterable is empty.
read-only

lastOrNull → T?

The last element, or null if the iterable is empty.
read-only

singleOrNull → T?

The single element of the iterable, or null. ...
read-only

Methods

expandIndexed<R>(Iterable<R> expend(int index, T element)) Iterable<R>

Expands each element and index to a number of elements in a new iterable.

firstWhereIndexedOrNull(bool test(int index, T element)) T?

The first element whose value and index satisfies test. ...

firstWhereOrNull(bool test(T element)) T?

The first element satisfying test, or null if there are none.

foldIndexed<R>(R initialValue, R combine(int index, R previous, T element)) R

Combine the elements with a value and the current index. ...

forEachIndexed(void action(int index, T element)) void

Takes an action for each element. ...

forEachIndexedWhile(bool action(int index, T element)) void

Takes an action for each element and index as long as desired. ...

forEachWhile(bool action(T element)) void

Takes an action for each element as long as desired. ...

groupFoldBy<K, G>(K keyOf(T element), G combine(G? previous, T element)) Map<K, G>

Groups elements by keyOf then folds the elements in each group. ...

groupListsBy<K>(K keyOf(T element)) Map<K, List<T>>

Groups elements into lists by keyOf.

groupSetsBy<K>(K keyOf(T element)) Map<K, Set<T>>

Groups elements into sets by keyOf.

isSorted(Comparator<T> compare) bool

Whether the elements are sorted by the compare ordering. ...

isSortedBy<K extends Comparable<K>>(K keyOf(T element)) bool

Whether the elements are sorted by their keyOf property. ...

isSortedByCompare<K>(K keyOf(T element), Comparator<K> compare) bool

Whether the elements are compare-sorted by their keyOf property. ...

lastWhereIndexedOrNull(bool test(int index, T element)) T?

The last element whose index and value satisfies test. ...

lastWhereOrNull(bool test(T element)) T?

The last element satisfying test, or null if there are none.

mapIndexed<R>(R convert(int index, T element)) Iterable<R>

Maps each element and its index to a new value.

none(bool test(T)) bool

Whether no element satisfies test. ...

reduceIndexed(T combine(int index, T previous, T element)) T

Combine the elements with each other and the current index. ...

sample(int count, [Random? random]) List<T>

Selects count elements at random from this iterable. ...

singleWhereIndexedOrNull(bool test(int index, T element)) T?

The single element satisfying test. ...

singleWhereOrNull(bool test(T element)) T?

The single element satisfying test. ...

sorted(Comparator<T> compare) List<T>

Creates a sorted list of the elements of the iterable. ...

sortedBy<K extends Comparable<K>>(K keyOf(T element)) List<T>

Creates a sorted list of the elements of the iterable. ...

sortedByCompare<K>(K keyOf(T element), Comparator<K> compare) List<T>

Creates a sorted list of the elements of the iterable. ...

splitAfter(bool test(T element)) Iterable<List<T>>

Splits the elements into chunks before some elements. ...

splitAfterIndexed(bool test(int index, T element)) Iterable<List<T>>

Splits the elements into chunks after some elements and indices. ...

splitBefore(bool test(T element)) Iterable<List<T>>

Splits the elements into chunks before some elements. ...

splitBeforeIndexed(bool test(int index, T element)) Iterable<List<T>>

Splits the elements into chunks before some elements and indices. ...

splitBetween(bool test(T first, T second)) Iterable<List<T>>

Splits the elements into chunks between some elements. ...

splitBetweenIndexed(bool test(int index, T first, T second)) Iterable<List<T>>

Splits the elements into chunks between some elements and indices. ...

whereIndexed(bool test(int index, T element)) Iterable<T>

The elements whose value and index satisfies test.

whereNot(bool test(T element)) Iterable<T>

The elements that do not satisfy test.

whereNotIndexed(bool test(int index, T element)) Iterable<T>

The elements whose value and index do not satisfy test.