PlayxIterableExtensions<T> extension

Extensions on Iterable class to make it easier to work with.

on

Properties

random → T?
Returns a random item from the list or null if the list is empty.
no setter

Methods

asyncMap<S>(FutureOr<S> action(T e)) Future<List<S>>
Asynchronously map each element of this collection by action.
atOr(int index, T value) → T
Returns the element at the given index or value if the index is out of bounds of this list.
atOrNull(int index) → T?
Returns the element at the given index or null if the index is out of bounds of this list.
countNotNull() int
Count the number of elements that are not null.
countWhere([bool predicate(T element)?]) int
Count the number of elements that satisfy predicate predicate.
firstOr(T value) → T
Returns the first element if list is not empty. Otherwise, return value
firstOrNull() → T?
Returns first element if list is not empty.
firstWhereOr(bool predicate(T e), T value) → T
Returns the element where equals predicate or value if not found.
firstWhereOrNull(bool predicate(T e)) → T?
Returns the element where equals predicate or null if not found.
isIndexValid(int index) bool
Checks if the item with index exists or not in the list.
lastOr(T value) → T
Returns the last element if list is not empty. Otherwise, return value
lastOrNull() → T?
Returns last element if list is not empty.
lastWhereOr(bool predicate(T e), T value) → T
Returns the element where equals predicate or value if not found.
lastWhereOrNull(bool predicate(T e)) → T?
Returns the element where equals predicate or null if not found.
mapWithIndex<E>(E mapper(int index, T element)) List<E>
Map each element of the list to a MapEntry with it's index and returns the resulting map.
withoutDuplicate() List<T>
Returns a new list after removing duplicates from the original list.