CollectionsExtensions<T> extension
- on
-
- Iterable<
T>
- Iterable<
Properties
- fourth → T
-
Available on Iterable<
Fourth element.T> , provided by the CollectionsExtensions extensionno setter - getRandom → dynamic
-
Available on Iterable<
Retrieves a random element from the current Iterable.T> , provided by the CollectionsExtensions extensionno setter - halfLength → int
-
Available on Iterable<
Calculates and returns the half length of the current Iterable as an integer.T> , provided by the CollectionsExtensions extensionno setter - random → T
-
Available on Iterable<
Returns a random element from the list.T> , provided by the CollectionsExtensions extensionno setter -
reversed
→ Iterable<
T> -
Available on Iterable<
Returns a new iterable with the elements of this iterable in reverse order.T> , provided by the CollectionsExtensions extensionno setter - second → T
-
Available on Iterable<
Second element.T> , provided by the CollectionsExtensions extensionno setter - third → T
-
Available on Iterable<
Third element.T> , provided by the CollectionsExtensions extensionno setter -
withoutDups
→ List<
T> -
Available on Iterable<
Returns a new list that contains the unique elements of the original list.T> , provided by the CollectionsExtensions extensionno setter
Methods
-
all(
bool predicate(T element)) → bool -
Available on Iterable<
Returns true if all elements match the givenT> , provided by the CollectionsExtensions extensionpredicate
or if the collection is empty. -
any(
bool predicate(T element)) → bool -
Available on Iterable<
Checks if any element in the list satisfies the givenT> , provided by the CollectionsExtensions extensionpredicate
. -
append(
Iterable< T> elements) → Iterable<T> -
Available on Iterable<
T> , provided by the CollectionsExtensions extension -
associate(
dynamic key(dynamic element), dynamic value(dynamic element)) → Map -
Available on Iterable<
Creates a new Map by associating each element in the Iterable with a key-value pair.T> , provided by the CollectionsExtensions extension -
averageBy(
num selector(T element)) → double -
Available on Iterable<
Calculates the average of the selected values from all elements in the collection.T> , provided by the CollectionsExtensions extension -
chunked(
int size) → Iterable< List< T> > -
Available on Iterable<
Returns a new lazy Iterable where elements are grouped into chunks of a specifiedT> , provided by the CollectionsExtensions extensionsize
. -
clearSublist(
[String sublistName = 'checks']) → List< T> -
Available on Iterable<
Returns a new list where the specified sublist in each entry is cleared.T> , provided by the CollectionsExtensions extension -
containsAny(
List< T> elements) → bool -
Available on Iterable<
Determines if the calling list contains any elements from the provided list.T> , provided by the CollectionsExtensions extension -
containsMapKey(
Map entity) → bool -
Available on Iterable<
Checks if any map in the list contains the specifiedT> , provided by the CollectionsExtensions extensionentity
key. -
count(
[bool predicate(T element)?]) → int -
Available on Iterable<
Counts the number of elements in the current Iterable that satisfy the givenT> , provided by the CollectionsExtensions extensionpredicate
. -
cycle(
[int n = 0]) → Iterable< T> -
Available on Iterable<
Creates an iterable that cycles through the elements of this iterable.T> , provided by the CollectionsExtensions extension -
distinct(
) → Iterable< T> -
Available on Iterable<
Returns a new lazy Iterable containing only distinct elements.T> , provided by the CollectionsExtensions extension -
distinctBy(
dynamic predicate(T selector)) → List< T> -
Available on Iterable<
Creates a new List containing distinct elements based on the result of the givenT> , provided by the CollectionsExtensions extensionpredicate
. -
drop(
int n) → List< T> -
Available on Iterable<
Returns a list containing all elements except firstT> , provided by the CollectionsExtensions extensionn
elements. -
elementAtOrDefault(
int index, T defaultValue) → T -
Available on Iterable<
Returns an element at the givenT> , provided by the CollectionsExtensions extensionindex
ordefaultValue
if theindex
is out of bounds of this collection. -
elementAtOrElse(
int index, T defaultValue(int index)) → T -
Available on Iterable<
Returns an element at the givenT> , provided by the CollectionsExtensions extensionindex
or the result of calling thedefaultValue
function if theindex
is out of bounds of this collection. -
except(
Iterable< T> elements) → Iterable<T> -
Available on Iterable<
Yields elements from this iterable that are not present in theT> , provided by the CollectionsExtensions extensionelements
iterable. -
exceptElement(
T element) → Iterable< T> -
Available on Iterable<
Yields elements from this iterable that are not equal to the specifiedT> , provided by the CollectionsExtensions extensionelement
. -
fillSublist(
T newValue, [String sublistName = 'checks']) → List< T> -
Available on Iterable<
Returns a new list where all elements of the specified sublist are replaced with a given value.T> , provided by the CollectionsExtensions extension -
filter(
bool test(T element)) → List< T> -
Available on Iterable<
Creates a new List containing only the elements that satisfy the givenT> , provided by the CollectionsExtensions extensiontest
function. -
filterIndexed(
bool predicate(T element, int index)) → Iterable< T> -
Available on Iterable<
Returns all elements that satisfy the givenT> , provided by the CollectionsExtensions extensionpredicate
. -
filterIndexedTo(
List< T> destination, bool predicate(T element, int index)) → void -
Available on Iterable<
Appends all elements matching the givenT> , provided by the CollectionsExtensions extensionpredicate
to the givendestination
. -
filterNotIndexed(
bool predicate(T element, int index)) → Iterable< T> -
Available on Iterable<
Returns all elements not matching the givenT> , provided by the CollectionsExtensions extensionpredicate
. -
filterNotNull(
) → Iterable< T> -
Available on Iterable<
Returns a new lazy Iterable with all elements which are not null.T> , provided by the CollectionsExtensions extension -
filterNotTo(
List< T> destination, bool predicate(T element)) → void -
Available on Iterable<
Appends all elements not matching the givenT> , provided by the CollectionsExtensions extensionpredicate
to the givendestination
. -
filterNotToIndexed(
List< T> destination, bool predicate(T element, int index)) → void -
Available on Iterable<
Appends all elements not matching the givenT> , provided by the CollectionsExtensions extensionpredicate
to the givendestination
. -
filterTo(
List< T> destination, bool predicate(T element)) → void -
Available on Iterable<
Appends all elements matching the givenT> , provided by the CollectionsExtensions extensionpredicate
to the givendestination
. -
find(
dynamic predicate(T selector)) → T? -
Available on Iterable<
Finds the first element in the Iterable that satisfies the givenT> , provided by the CollectionsExtensions extensionpredicate
. -
firstHalf(
) → List< T> -
Available on Iterable<
Takes the first half of a listT> , provided by the CollectionsExtensions extension -
firstWhereOrNull(
bool test(T)) → T? -
Available on Iterable<
Returns the first element that satisfies the givenT> , provided by the CollectionsExtensions extensiontest
function, ornull
if no element matches. -
firstWhile(
bool predicate(T element)) → Iterable< T> -
Available on Iterable<
Yields elements from the iterable as long as theT> , provided by the CollectionsExtensions extensionpredicate
condition is met. -
flatMap<
R> (Iterable< R> transform(T element)) → Iterable<R> -
Available on Iterable<
Returns a new lazy Iterable containing elements yielded from the results of theT> , provided by the CollectionsExtensions extensiontransform
function being invoked on each element of this collection. -
flatten(
) → Iterable -
Available on Iterable<
Returns a new lazy Iterable where all elements of nested Iterables are flattened.T> , provided by the CollectionsExtensions extension -
getRandomValueByFieldName(
String fieldname) → String -
Available on Iterable<
Retrieves a random value from an element in the current Iterable based on the specifiedT> , provided by the CollectionsExtensions extensionfieldname
. -
groupBy<
T, String> (String mapper(T e), {Iterable order = const [], Iterable pinned = const []}) → Map< String, List< T> > -
Available on Iterable<
Groups the elements of the current Iterable by a key derived from each element.T> , provided by the CollectionsExtensions extension -
joinToString(
{String separator = ', ', String transform(T element)?, String prefix = '', String postfix = '', int limit = 0, String truncated = '...'}) → String -
Available on Iterable<
Creates a string from all the elements separated usingT> , provided by the CollectionsExtensions extensionseparator
and using the givenprefix
andpostfix
if supplied. -
keyInList(
int index) → bool -
Available on Iterable<
Checks if theT> , provided by the CollectionsExtensions extensionindex
is within the bounds of the iterable. -
lastOrNullWhere(
bool predicate(T element)) → T -
Available on Iterable<
Returns the last element matching the givenT> , provided by the CollectionsExtensions extensionpredicate
, ornull
if no such element was found. -
lastWhile(
bool predicate(T element)) → Iterable< T> -
Available on Iterable<
Yields elements from the end of the iterable as long as theT> , provided by the CollectionsExtensions extensionpredicate
condition is met. -
mapIndexed<
R> (R transform(int index, T)) → Iterable< R> -
Available on Iterable<
Returns a new lazy Iterable containing only the non-null results of applying the givenT> , provided by the CollectionsExtensions extensiontransform
function to each element in the original collection. Returns a new lazy Iterable containing the results of applying the giventransform
function to each element of this collection, where the function takes two arguments: the index of the current element and the element itself. -
mapIndexedNotNull<
R> (R transform(int index, T)) → Iterable< R> -
Available on Iterable<
Returns a new lazy Iterable containing the results of applying the givenT> , provided by the CollectionsExtensions extensiontransform
function to each element of this collection, where the function takes two arguments: the index of the current element and the element itself, and filters out the elements for which thetransform
function returnsnull
. -
mapList<
T> (T f(dynamic doc)) → List< T> -
Available on Iterable<
Applies the provided functionT> , provided by the CollectionsExtensions extensionf
to each element in the current Iterable and returns a new List containing the transformed elements. -
mapNotNull<
R> (R transform(T element)) → Iterable< R> -
Available on Iterable<
Returns a new lazy Iterable containing the non-null results of applying the givenT> , provided by the CollectionsExtensions extensiontransform
function to each element of this collection. -
mapToOptions<
T> (String key, String title) → Map< String, Map> -
Available on Iterable<
Maps the current iterable to a Map where each key represents a unique date and the corresponding value is a List of elements assigned on that date.T> , provided by the CollectionsExtensions extension -
max(
) → T -
Available on Iterable<
Returns the largest element orT> , provided by the CollectionsExtensions extensionnull
if there are no elements. -
maxBy(
Comparable selector(T element)) → T -
Available on Iterable<
Returns the first element yielding the largest value of the givenT> , provided by the CollectionsExtensions extensionselector
ornull
if there are no elements. -
maxWith(
Comparator< T> comparator) → T -
Available on Iterable<
Returns the first element having the largest value according to the providedT> , provided by the CollectionsExtensions extensioncomparator
ornull
if there are no elements. -
min(
) → T -
Available on Iterable<
Returns the smallest element orT> , provided by the CollectionsExtensions extensionnull
if there are no elements. -
minBy(
Comparable selector(T element)) → T -
Available on Iterable<
Returns the first element yielding the smallest value of the givenT> , provided by the CollectionsExtensions extensionselector
ornull
if there are no elements. -
minWith(
Comparator< T> comparator) → T -
Available on Iterable<
Returns the first element having the smallest value according to the providedT> , provided by the CollectionsExtensions extensioncomparator
ornull
if there are no elements. -
none(
bool predicate(T element)) → bool -
Available on Iterable<
Returns true if no entries match the givenT> , provided by the CollectionsExtensions extensionpredicate
or if the collection is empty. -
onEach(
void action(T element)) → Iterable< T> -
Available on Iterable<
Invokes the specifiedT> , provided by the CollectionsExtensions extensionaction
for each element in the iterable and returns a new lazy iterable that yields the same elements. -
onlyOwned<
T> (String uid) → List< T> -
Available on Iterable<
Returns a new list containing only the elements that are owned by the specifiedT> , provided by the CollectionsExtensions extensionuid
. -
requireNoNulls(
) → void -
Available on Iterable<
Returns an original collection containing all the non-null elements, throwing an StateError if there are any null elements.T> , provided by the CollectionsExtensions extension -
secondHalf(
) → List< T> -
Available on Iterable<
Takes the second half of a listT> , provided by the CollectionsExtensions extension -
shuffled(
Random random) → List< T> -
Available on Iterable<
Returns a new List containing all elements of this iterable in a random order.T> , provided by the CollectionsExtensions extension -
slice(
int start, [int end = -1]) → List< T> -
Available on Iterable<
Creates a slice of a list fromT> , provided by the CollectionsExtensions extensionstart
up to, but not including,end
. -
sorted(
) → List< T> -
Available on Iterable<
Returns a new list containing all elements sorted in ascending order.T> , provided by the CollectionsExtensions extension -
sortedByTime(
Comparable key(T e), {bool reversed = false}) → List< T> -
Available on Iterable<
T> , provided by the CollectionsExtensions extension -
sortedByTimeOnly(
DateTime key(T e), {bool reversed = false}) → List< T> -
Available on Iterable<
Returns a new list sorted based on the time extracted from the givenT> , provided by the CollectionsExtensions extensionkey
function. Thekey
function should return a DateTime value from which the time is extracted (ignoring the date). -
sortedByValue(
Comparable key(T e), {bool reversed = false}) → List< T> -
Available on Iterable<
Returns a new list sorted based on the values derived from the givenT> , provided by the CollectionsExtensions extensionkey
function. -
subtract(
Iterable< T> other) → dynamic -
Available on Iterable<
Creates a new Set that contains all the elements of the current Set except for the elements that are also present in theT> , provided by the CollectionsExtensions extensionother
Iterable. -
sumBy(
num selector(T element)) → double -
Available on Iterable<
Calculates the sum of the selected values from all elements in the collection.T> , provided by the CollectionsExtensions extension -
sumByValue(
num selector(T)) → double -
Available on Iterable<
Calculates the sum of a list of objects based on a specific property value.T> , provided by the CollectionsExtensions extension -
swap(
int i, int j) → List< T> -
Available on Iterable<
Creates a new List with the elements at positionsT> , provided by the CollectionsExtensions extensioni
andj
swapped. -
takeFirst(
int n) → List< T> -
Available on Iterable<
Returns a new list containing the firstT> , provided by the CollectionsExtensions extensionn
elements from this iterable. -
takeLast(
int n) → List< T> -
Available on Iterable<
Returns a new list containing the lastT> , provided by the CollectionsExtensions extensionn
elements from this iterable. -
toHashSet(
) → HashSet< T> -
Available on Iterable<
Creates a new HashSet containing all the elements of this iterable.T> , provided by the CollectionsExtensions extension -
toIterable(
) → Iterable< T> -
Available on Iterable<
Returns a new lazy Iterable containing all elements of this collection.T> , provided by the CollectionsExtensions extension -
toMutableSet(
) → Set< T> -
Available on Iterable<
Converts the current Set to a mutable Set.T> , provided by the CollectionsExtensions extension -
toUnmodifiable(
) → List< T> -
Available on Iterable<
Creates an unmodifiable List containing all the elements of this iterable.T> , provided by the CollectionsExtensions extension -
union(
Iterable< T> other) → Iterable<T> -
Available on Iterable<
Returns a new lazy Iterable that represents the union of this iterable and theT> , provided by the CollectionsExtensions extensionother
iterable. -
whereIndexed(
bool predicate(T element, int index)) → Iterable< T> -
Available on Iterable<
Returns all elements that satisfy the givenT> , provided by the CollectionsExtensions extensionpredicate
. -
whereIndexedTo(
List< T> destination, bool predicate(T element, int index)) → void -
Available on Iterable<
Appends all elements that satisfy the givenT> , provided by the CollectionsExtensions extensionpredicate
(which includes the element's index) to thedestination
list. -
whereNot(
bool predicate(T element)) → Iterable< T> -
Available on Iterable<
Yields all elements of the iterable for which theT> , provided by the CollectionsExtensions extensionpredicate
returnsfalse
. -
whereNotIndexed(
bool predicate(T element, int index)) → Iterable< T> -
Available on Iterable<
Yields all elements of the iterable for which theT> , provided by the CollectionsExtensions extensionpredicate
(including the element's index) returnsfalse
. -
whereNotNull(
) → Iterable< T> -
Available on Iterable<
Returns a new lazy Iterable containing all elements of this collection that are notT> , provided by the CollectionsExtensions extensionnull
. -
whereNotTo(
List< T> destination, bool predicate(T element)) → void -
Available on Iterable<
Appends all elements not matching the givenT> , provided by the CollectionsExtensions extensionpredicate
to the givendestination
. -
whereNotToIndexed(
List< T> destination, bool predicate(T element, int index)) → void -
Available on Iterable<
Appends all elements not matching the givenT> , provided by the CollectionsExtensions extensionpredicate
(which includes the element's index) to the givendestination
. -
whereTo(
List< T> destination, bool predicate(T element)) → void -
Available on Iterable<
Appends all elements that satisfy the givenT> , provided by the CollectionsExtensions extensionpredicate
to thedestination
list.
Operators
-
operator +(
Iterable< T> elements) → List<T> -
Available on Iterable<
Returns a new lazy Iterable that appends the givenT> , provided by the CollectionsExtensions extensionelements
iterable to this iterable. -
operator -(
Iterable< T> elements) → List<T> -
Available on Iterable<
Returns a new list of elements from this iterable with the elements fromT> , provided by the CollectionsExtensions extensionelements
excluded.