ImmutableList<T> class

A list that cannot be modified after it's created.

This is a wrapper around a standard Dart list that provides an unmodifiable view of the original list. This ensures that the underlying list cannot be changed once the ImmutableList object has been constructed.

Example:

final immutableList = ImmutableList([1, 2, 3]);
print(immutableList.first); // prints 1
Implemented types
Available Extensions

Constructors

ImmutableList(List<T> items)
Constructs an ImmutableList.

Properties

first → T
Gets the first element in the list.
read-onlyoverride
hashCode int
The hash code for this object.
read-onlyoverride
isEmpty bool
Returns true if there are no elements in this collection.
read-onlyoverride
isNotEmpty bool
Returns true if there is at least one element in this collection.
read-onlyoverride
items UnmodifiableListView<T>
Provides an unmodifiable view of the items.
read-only
iterator Iterator<T>
A new Iterator that allows iterating the elements of this Iterable.
read-onlyoverride
last → T
Gets the last element in the list.
read-onlyoverride
length int
Returns the number of items in the list.
read-onlyoverride
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
single → T
Gets the single element in the list. Throws an error if the list has more than one item.
read-onlyoverride

Methods

any(bool test(T)) bool
Checks if any item in the list satisfies the provided test.
override
cast<R>() Iterable<R>
Casts the items of the list to the desired type R.
override
contains(Object? element) bool
Determines if the list contains the provided element.
override
elementAt(int index) → T
Returns the element at the specified index.
override
every(bool test(T)) bool
Checks if every item in the list satisfies the provided test.
override
expand<T0>(Iterable<T0> f(T)) Iterable<T0>
Expands each element into zero or more elements.
override
firstWhere(bool test(T), {T orElse()?}) → T
Gets the first element that satisfies the given predicate test. If none are found, it calls the orElse function if provided.
override
fold<T0>(T0 initialValue, T0 combine(T0, T)) → T0
Accumulates value starting with initialValue and applying combine for each element in order.
override
followedBy(Iterable<T> other) Iterable<T>
Appends all elements of other to the end of this iterable's elements.
override
forEach(void f(T)) → void
Applies the function f to each element of this collection.
override
join([String separator = ""]) String
Converts the items in the list to a string and concatenates them using the provided separator.
override
lastWhere(bool test(T), {T orElse()?}) → T
Gets the last element that satisfies the given predicate test. If none are found, it calls the orElse function if provided.
override
map<T0>(T0 f(T)) Iterable<T0>
Applies the function f to each element in the list and returns a new iterable with elements of type T0.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reduce(T combine(T, T)) → T
Reduces the elements in the list to a single value using the combine function.
override
singleWhere(bool test(T), {T orElse()?}) → T
Gets the single element that satisfies the given predicate test. If none are found, it calls the orElse function if provided.
override
skip(int count) Iterable<T>
Skips the first count elements.
override
skipWhile(bool test(T)) Iterable<T>
Skips while elements satisfy the given predicate test.
override
take(int count) Iterable<T>
Takes the first count elements.
override
takeWhile(bool test(T)) Iterable<T>
Takes while elements satisfy the given predicate test.
override
toList({bool growable = true}) List<T>
Returns a list representation of the iterable.
override
toSet() Set<T>
Returns a set representation of the iterable.
override
toString() String
Returns a string representation of the list.
override
where(bool test(T)) Iterable<T>
Filters the elements in the list based on the predicate test.
override
whereType<T1>() Iterable<T1>
Returns an iterable of objects of type T, where T is a subtype of T.
override

Operators

operator ==(Object other) bool
The equality operator.
override