IterableSC<T> extension

Supercharged extensions on Iterables like List and Set.

on

Properties

lastIndex int?
Returns the last accessible index. If collection is empty this returns null.
no setter

Methods

associate<K, V>(MapEntry<K, V> transform(T element)) Map<K, V>
Returns a map that contains MapEntrys provided by a transform function.
associateBy<K>(K keySelector(T element)) Map<K, T>
Returns a map where every element is associated by a key produced from the keySelector function.
associateWith<V>(V valueSelector(T element)) Map<T, V>
Returns a map where every element is used as a key that is associated with a value produced by the valueSelector function.
averageBy(num selector(T)) double?
Returns the average value (arithmetic mean) of all values produces by the selector function that is applied to each element.
chunked(int size, {T fill()?}) Iterable<List<T>>
Splits the elements into lists of the specified size.
count([bool test(T element)?]) int
Returns the number of elements that matches the test.
elementAtOrElse(int index, T orElse()) → T
Returns the indexth element. If the index is out of bounds the orElse supplier function is called to provide a value.
elementAtOrNull(int index) → T?
Deprecation hint: Read the migration guide for more details on migrating.
filter(bool test(T element)) Iterable<T>
Returns a new Iterable with all elements that satisfy the predicate test.
firstOrElse(T orElse()) → T
Returns the first element. If there is no first element the orElse supplier function is called to provide a value.
firstOrNullSC() → T?
Deprecation hint: Read the migration guide for more details on migrating.
forEachIndexedSC(void funcIndexValue(int index, T element)) → void
Deprecation hint: Read the migration guide for more details on migrating.
groupBy<K, V>(K keySelector(T element), {V valueTransform(T element)?}) Map<K, List<V>>
Groups the elements of the list into a map by a key that is defined by a keySelector function.
lastOrElse(T orElse()) → T
Returns the last element. If there is no last element the orElse supplier function is called to provide a value.
lastOrNullSC() → T?
Deprecation hint: Read the migration guide for more details on migrating.
mapIndexedSC<U>(U transformer(T currentValue, int index)) Iterable<U>
Deprecation hint: Read the migration guide for more details on migrating.
maxBy(Comparator<T> comparator) → T?
Returns the maximum value based on the comparator function. If collection is empty this returns null.
minBy(Comparator<T> comparator) → T?
Returns the minimal value based on the comparator function. If collection is empty this returns null.
onEach(void action(T element)) Iterable<T>
Applies the given action on each element and also returns the whole Iterable without modifying it.
onEachIndexed(void action(T element, int index)) Iterable<T>
Applies the given action on each element and also returns the whole Iterable without modifying it. The action takes a second parameter index matching the element index.
pickOne([Random? random]) → T
Returns a random item. The randomness can be customized by setting random.
pickSome(int count, [Random? random]) List<T>
Returns an List of count random items. The randomness can be customized by setting random.
replaceFirstWhere(bool comparator(T currentValue), T newValue) Iterable<T>
Replaces the first element that matches the comparator with newValue.
replaceWhere(bool comparator(T currentValue), T newValue) Iterable<T>
Replaces every element that matches the comparator with newValue.
sortedByNumSC(num valueProvider(T element)) List<T>
Deprecation hint: Read the migration guide for more details on migrating.
sortedBySC(Comparator<T> comparator) List<T>
Deprecation hint: Read the migration guide for more details on migrating.
sortedByStringSC(String valueProvider(T element)) List<T>
Deprecation hint: Read the migration guide for more details on migrating.
sumBy(int selector(T)) int
Returns the sum of all values produced by the selector function that is applied to each element.
sumByDouble(num selector(T)) double
Returns the sum of all values produced by the selector function that is applied to each element.
withoutFirst() Iterable<T>
Lazily returns all values without the first one.
withoutLast() Iterable<T>
Lazily returns all values without the last one.