FicIterableExtension<T> extension
See also: FicListExtension, FicSetExtension
- on
-
- Iterable<
T>
- Iterable<
Methods
-
anyIs(
T value) → bool -
Returns
true
if any item is equal tovalue
. -
asList(
) → List< T> - Returns a List containing the elements of this iterable. If the Iterable is already a List, return the same instance (nothing new is created). Otherwise, create a new List from it. See also: Dart's native toList, which always creates a new list.
-
asSet(
) → Set< T> - Creates a Set containing the same elements as this iterable. If the Iterable is already a Set, return the same instance (nothing new is created). Otherwise, create a new Set from it. See also: Dart's native toSet, which always creates a new set.
-
averageBy<
N extends num> (N mapper(T element)) → double - The arithmetic mean of the elements of a non-empty iterable. The arithmetic mean is the sum of the elements divided by the number of elements. If iterable is empty it returns 0. Examples:
-
deepEquals(
Iterable? other, {bool ignoreOrder = false}) → bool -
Compare all items, in order or not, according to
ignoreOrder
, using operator ==. Return true if they are all the same, in the same order. -
deepEqualsByIdentity(
Iterable? other, {bool ignoreOrder = false}) → bool -
Return true if they are all the same, in the same order.
Compare all items, in order or not, according to
ignoreOrder
, using identical. Return true if they are all the same, in the same order. -
everyIs(
T value) → bool -
Returns
true
if all items are equal tovalue
. -
findDuplicates(
) → Set< T> - Finds duplicates and then returns a Set with the duplicated elements. If there are no duplicates, an empty Set is returned.
-
isFirst(
T item) → bool -
Return true if the given
item
is the same (by identity) as the first iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you have the first item. For example: -
isLast(
T item) → bool -
Return true if the given
item
is the same (by identity) as the last iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you have the last item. For example: -
isNotFirst(
T item) → bool -
Return true if the given
item
is NOT the same (by identity) as the first iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you don't have the first item. For example: -
isNotLast(
T item) → bool -
Return true if the given
item
is NOT the same (by identity) as the last iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you don't have the last item. For example: -
mapIndexedAndLast<
R> (R convert(int index, T item, bool isLast)) → Iterable< R> -
Maps each element and its index to a new value.
This is similar to
mapIndexed
but also tells you which item is the last. -
restrict(
T? item, {required T orElse}) → T - Restricts some item to one of those present in this iterable.
-
sortedLike(
Iterable ordering) → List< T> -
Returns a list, sorted according to the order specified by the
ordering
iterable. Items which don't appear inordering
will be included in the end, in their original order. Items ofordering
which are not found in the original list are ignored. -
sortedReversed(
[Comparator< T> ? compare]) → List<T> - Creates a reversed sorted list of the elements of the iterable.
-
sumBy<
N extends num> (N mapper(T element)) → N -
The sum of the values returned by the
mapper
function. -
toIList(
[ConfigList? config]) → IList< T> - Creates an immutable list (IList) from the iterable.
-
toISet(
[ConfigSet? config]) → ISet< T> - Creates an immutable set (ISet) from the iterable.
-
updateById(
Iterable< T> newItems, dynamic id(T item)) → List<T> -
Returns a new list where
newItems
are added or updated, by theirid
(and theid
is a function of the item), like so: -
whereNoDuplicates(
{dynamic by(T item)?, bool removeNulls = false}) → Iterable< T> -
Removes all duplicates, leaving only the distinct items.
Optionally, you can provide an
by
function to compare the items.