ListExtension<E> extension
Provides convenient List extensions
- on
-
- List<
E>
- List<
Methods
-
addAllIfNotNull(
List< E> ? items) → void -
Available on List<
Adds all items fromE> , provided by the ListExtension extensionitems
to the list ifitems
is not null or empty. -
addIfNotNull(
E? item) → void -
Available on List<
AddsE> , provided by the ListExtension extensionitem
to the list ifitem
is not null. -
all(
bool test(E e)) → bool -
Available on List<
Returns true if all elements in the list satisfy the givenE> , provided by the ListExtension extensiontest
. -
any(
bool test(E e)) → bool -
Available on List<
Returns true if any element in the list satisfies the givenE> , provided by the ListExtension extensiontest
. -
chunk(
int chunkSize) → List< List< E> > -
Available on List<
Returns a new list containing chunks of the original list with the specifiedE> , provided by the ListExtension extensionchunkSize
. -
evenList(
) → List< E> -
Available on List<
Returns a new list containing elements at even indices.E> , provided by the ListExtension extension -
oddList(
) → List< E> -
Available on List<
Returns a new list containing elements at odd indices.E> , provided by the ListExtension extension -
randomElement(
) → E? -
Available on List<
Safely returns a random element from the list. Returns null if the list is empty.E> , provided by the ListExtension extension -
safeGet(
int index) → E? -
Available on List<
Safely returns the element at the givenE> , provided by the ListExtension extensionindex
. Returns null if the index is out of bounds. -
skipFrom(
int start) → List< E> -
Available on List<
Returns a new list containing elements from this list starting fromE> , provided by the ListExtension extensionstart
. -
swap(
int index1, int index2) → void -
Available on List<
Swaps the elements atE> , provided by the ListExtension extensionindex1
andindex2
. Throws a RangeError if indices are out of bounds. -
takeUpTo(
int end) → List< E> -
Available on List<
Returns a new list containing elements from this list up to, but not including,E> , provided by the ListExtension extensionend
. -
to<
T> (T generator(E e)) → List< T> -
Available on List<
Maps each element of this list to a new value and returns a new list. This is equivalent toE> , provided by the ListExtension extensionmap(generator).toList()
. -
whereToList(
bool test(E e)) → List< E> -
Available on List<
Returns a new list containing elements that satisfy the givenE> , provided by the ListExtension extensiontest
.