IterableExtensions<T> extension

Common iterable extensions

on

Properties

unique List<T>

Available on Iterable<T>, provided by the IterableExtensions extension

Returns a new list containing the unique elements from the original iterable.
no setter

Methods

averageBy(num selector(T)) num

Available on Iterable<T>, provided by the IterableExtensions extension

Calculates the average value of all elements in the iterable by mapping them to numeric values.
count(bool test(T element)) int

Available on Iterable<T>, provided by the IterableExtensions extension

Counts the number of elements that satisfy the test.
distinctBy(Object? selector(T e)) List<T>

Available on Iterable<T>, provided by the IterableExtensions extension

Returns a list of unique elements based on a selector function.
firstWhereOrNull(bool test(T)) → T?

Available on Iterable<T>, provided by the IterableExtensions extension

Tries to find the first element in the iterable that matches the given test. Returns null if no such element is found.
forEachIndexed(void f(int index, T element)) → void

Available on Iterable<T>, provided by the IterableExtensions extension

Iterates through the iterable with both index and element.
groupBy<K>(K keyFunction(T)) Map<K, List<T>>

Available on Iterable<T>, provided by the IterableExtensions extension

Groups the elements in the iterable according to the keyFunction. Returns a map where each key corresponds to a list of elements that share that key.
mapIndexed<E>(E f(int index, T element)) Iterable<E>

Available on Iterable<T>, provided by the IterableExtensions extension

Maps each element along with its index to a new value.
mapToList<E>(E convert(T)) List<E>

Available on Iterable<T>, provided by the IterableExtensions extension

Converts the iterable to a list using a convert function for each element.
sumBy(num selector(T)) num

Available on Iterable<T>, provided by the IterableExtensions extension

Calculates the sum of all elements in the iterable by mapping them to numeric values.
whereIndexed(bool test(int index, T element)) Iterable<T>

Available on Iterable<T>, provided by the IterableExtensions extension

Returns a new iterable containing elements that satisfy the test with their index.
windowed(int size, {int step = 1, bool partialWindows = false}) Iterable<List<T>>

Available on Iterable<T>, provided by the IterableExtensions extension

Returns a sliding window of a given size and optional step.
zip(Iterable other) Iterable<List>

Available on Iterable<T>, provided by the IterableExtensions extension

Zips this iterable with another other iterable.