IListConst<T> class

This is an IList which can be made constant. Note: Don't ever use it without the "const" keyword, because it will be unsafe.

Inheritance
Available Extensions
Annotations
  • @immutable

Constructors

IListConst(List<T> _list)
To create an empty IList: const IListConst([]). To create a list with items: const IListConst([1, 2, 3]).
const
IListConst.withConfig(List<T> _list, ConfigList config)
const

Properties

config ConfigList
finalgetter/setter pairinherited-setteroverride-getter
first → T
Returns the first element. Throws a StateError if the list is empty.
no setterinherited
firstOrNull → T?
Returns the first element, or null if the list is empty.
no setterinherited
flush IListConst<T>
Nothing happens when you flush a constant list, by definition.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
Returns the first element of this Iterable
no setterinherited
init Iterable<T>
Returns an Iterable that is the original iterable without the last element
no setterinherited
isDeepEquals bool
See also: ConfigList
no setterinherited
isEmpty bool
Returns true if there are no elements in this collection.
no setterinherited
isFlushed bool
A constant list is always flushed, by definition.
no setteroverride
isIdentityEquals bool
See also: ConfigList
no setterinherited
isNotEmpty bool
Returns true if there is at least one element in this collection.
no setterinherited
iterator Iterator<T>
Returns a new Iterator that allows iterating the elements of this IList.
no setterinherited
last → T
Returns the last element. Throws a StateError if the list is empty.
no setterinherited
lastOrNull → T?
Returns the last element, or null if the list is empty.
no setterinherited
length int
The number of objects in this list.
no setterinherited
reversed IList<T>
Returns an Iterable of the objects in this list in reverse order.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
single → T
Checks that this iterable has only one element, and returns that element. Throws a StateError if the list is empty or has more than one element.
no setterinherited
singleOrNull → T?
Checks that the list has only one element, and returns that element. Return null if the list is empty or has more than one element.
no setterinherited
tail Iterable<T>
Returns an Iterable that is the original iterable without head, aka first element
no setterinherited
unlock List<T>
Unlocks the list, returning a regular (mutable, growable) List. This list is "safe", in the sense that is independent from the original IList.
no setterinherited
unlockLazy List<T>
Unlocks the list, returning a safe, modifiable (mutable) List. Using this is very fast at first, since it makes no copies of the IList items. However, if and only if you use a method that mutates the list, like add, it will unlock internally (make a copy of all IList items). This is transparent to you, and will happen at most only once. In other words, it will unlock the IList, lazily, only if necessary. If you never mutate the list, it will be very fast to lock this list back into an IList.
no setterinherited
unlockView List<T>
Unlocks the list, returning a safe, unmodifiable (immutable) List view. The word "view" means the list is backed by the original IList. Using this is very fast, since it makes no copies of the IList items. However, if you try to use methods that modify the list, like add, it will throw an UnsupportedError. It is also very fast to lock this list back into an IList.
no setterinherited
withDeepEquals IList<T>
Creates a list with deepEquals (compares all list items by equality).
no setterinherited
withIdentityEquals IList<T>
Creates a list with identityEquals (compares the internals by identity).
no setterinherited

Methods

add(T item) IList<T>
Return a new list with item added to the end of the current list, (thus extending the length by one).
inherited
addAll(Iterable<T> items) IList<T>
Returns a new list with all items added to the end of the current list, (thus extending the length by the length of items).
inherited
any(Predicate<T> test) bool
Checks whether any element of this iterable satisfies test.
inherited
asMap() IMap<int, T>
Returns an IMap view of this list. The map uses the indices of this list as keys and the corresponding objects as values. The Map.keys Iterable iterates the indices of this list in numerical order.
inherited
cast<R>() Iterable<R>
Returns a list of R instances. If this list contains instances which cannot be cast to R, it will throw an error.
inherited
clear() IList<T>
Returns an empty list with the same configuration.
inherited
contains(covariant T? element) bool
Returns true if the collection contains an element equal to element, false otherwise.
inherited
corresponds<U>(Iterable<U> others, EQ eq) bool
Return true if length match and all Eq are true
inherited
count(Predicate<T> p) int
Positives predicate results count
inherited
divideIn2(bool test(T item)) IListOf2<IList<T>>
Divides the list into two. The first one contains all items which satisfy the provided test. The last one contains all the other items. The relative order of the items will be maintained.
inherited
elementAt(int index) → T
Returns the indexth element. This is the same as using the [] operator. See also: get and getOrNull.
inherited
equalItems(covariant Iterable? other) bool
Will return true only if the IList items are equal to the iterable items, and in the same order. This may be slow for very large lists, since it compares each item, one by one. You can compare the list with ordered sets, but unordered sets will throw a StateError. To compare the IList with unordered sets, try the unorderedEqualItems method.
inherited
equalItemsAndConfig(IList? other) bool
Will return true only if the list items are equal and in the same order, and the list configurations are equal. This may be slow for very large lists, since it compares each item, one by one.
inherited
every(Predicate<T> test) bool
Checks whether every element of this iterable satisfies test.
inherited
expand<E>(Iterable<E> f(T)) Iterable<E>
Expands each element of this Iterable into zero or more elements.
inherited
fillRange(int start, int end, [T? fillValue]) IList<T>
Sets the objects in the range start inclusive to end exclusive to the given fillValue.
inherited
firstOr(T orElse) → T
Returns the first element, or orElse if the list is empty.
inherited
firstWhere(Predicate<T> test, {T orElse()?}) → T
Iterates through elements and returns the first to satisfy test.
inherited
fold<E>(E initialValue, E combine(E previousValue, T element)) → E
Reduces a collection to a single value by iteratively combining eac element of the collection with an existing value.
inherited
followedBy(Iterable<T> other) Iterable<T>
Returns the lazy concatenation of this iterable and other.
inherited
forEach(void f(T element)) → void
Applies the function f to each element of this collection in iteration order.
inherited
get(int index, {T orElse(int index)?}) → T
Returns the indexth element. If that index doesn't exist (negative, or out of range), will return the result of calling orElse. In this case, if orElse is not provided, will throw an error.
inherited
getAndMap(int index, T map(int index, bool inRange, T? value)) → T
Gets the indexth element, and then apply the map function to it, returning the result. If that index doesn't exist (negative, or out of range), will the map method will be called with inRange false and value null.
inherited
getOrNull(int index) → T?
Returns the indexth element. If that index doesn't exist (negative or out of range), will return null. This method will never throw an error.
inherited
getRange(int start, int end) Iterable<T>
Returns an Iterable that iterates over the objects in the range start inclusive to end exclusive.
inherited
indexOf(T element, [int start = 0]) int
Returns the index of the first element in the list.
inherited
indexWhere(Predicate<T> test, [int start = 0]) int
Returns the first index in the list that satisfies the provided test.
inherited
inits() Iterable<Iterable<T>>
inherited
inRange(int index) bool
Returns true if the given index is valid (between 0 and length - 1).
inherited
insert(int index, T element) IList<T>
Inserts the object at position index in this list and returns a new immutable list.
inherited
insertAll(int index, Iterable<T> iterable) IList<T>
Inserts all objects of iterable at position index in this list.
inherited
join([String separator = ""]) String
Converts each element to a String and concatenates the strings with the separator in-between each concatenation.
inherited
lastIndexOf(T element, [int? start]) int
Returns the last index of element in this list.
inherited
lastIndexWhere(Predicate<T> test, [int? start]) int
Returns the last index in the list that satisfies the provided test.
inherited
lastOr(T orElse) → T
Returns the last element, or orElse if the list is empty.
inherited
lastWhere(Predicate<T> test, {T orElse()?}) → T
Returns the last element that satisfies the given predicate test.
inherited
lengthCompare(Iterable others) bool
Compare with others length
inherited
map<E>(E f(T element), {ConfigList? config}) Iterable<E>
Returns a new lazy Iterable with elements that are created by calling f on each element of this Iterable in iteration order.
inherited
maxLength(int maxLength, {int priority(T a, T b)?}) IList<T>
If the list has more than maxLength elements, remove the last elements so it remains with only maxLength elements. If the list has maxLength or less elements, doesn't change anything.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
process({bool test(IList<T> list, int index, T item)?, required Iterable<T>? convert(IList<T> list, int index, T item)}) IList<T>
Allows for complex processing of a list.
inherited
put(int index, T value) IList<T>
This is the equivalent to void operator []=(int index, T value); Sets the value at the given index in the list to value or throws a RangeError if index is out of bounds.
inherited
reduce(T combine(T value, T element)) → T
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
remove(T item) IList<T>
Removes the first occurrence of item from this IList.
inherited
removeAll(Iterable<T?> items) IList<T>
Removes all occurrences of all items from this list. Same as calling removeMany for each item in items.
inherited
removeAt(int index, [Output<T>? removedItem]) IList<T>
Removes the object at position index from this list.
inherited
removeDuplicates() IList<T>
Removes duplicates (but keeps items which appear only once, plus the first time other items appear).
inherited
removeLast([Output<T>? removedItem]) IList<T>
Pops and returns the last object in this list.
inherited
removeMany(T item) IList<T>
Removes all occurrences of item from this list.
inherited
removeNulls() IList<T>
Removes all nulls from this list.
inherited
removeNullsAndDuplicates() IList<T>
Removes duplicates (but keeps items which appear only once, plus the first time other items appear).
inherited
removeRange(int start, int end) IList<T>
Removes the objects in the range start inclusive to end exclusive.
inherited
removeWhere(Predicate<T> test) IList<T>
Removes all objects from this list that satisfy test.
inherited
replace(int index, T value) IList<T>
The replace method is the equivalent of operator []= for the IList.
inherited
replaceAll({required T from, required T to}) IList<T>
Finds all occurrences of from, and replace them with to.
inherited
replaceAllWhere(Predicate<T> test, T to) IList<T>
Finds all items that satisfy the provided test, and replace it with to.
inherited
replaceFirst({required T from, required T to}) IList<T>
Finds the first occurrence of from, and replace it with to.
inherited
replaceFirstWhere(bool test(T item), T to, {bool addIfNotFound = false}) IList<T>
Finds the first item that satisfies the provided test, and replace it with to.
inherited
replaceRange(int start, int end, Iterable<T> replacement) IList<T>
Removes the objects in the range start inclusive to end exclusive and inserts the contents of replacement in its place.
inherited
retainWhere(Predicate<T> test) IList<T>
Removes all objects from this list that fail to satisfy test.
inherited
same(IList<T>? other) bool
Will return true only if the lists internals are the same instances (comparing by identity). This will be fast even for very large lists, since it doesn't compare each item.
override
setAll(int index, Iterable<T> iterable) IList<T>
Overwrites objects of this with the objects of iterable, starting at position index in this list.
inherited
setRange(int start, int end, Iterable<T> iterable, [int skipCount = 0]) IList<T>
Copies the objects of iterable, skipping skipCount objects first, into the range start, inclusive, to end, exclusive, of the list.
inherited
shuffle([Random? random]) IList<T>
Shuffles the elements of this list randomly.
inherited
singleOr(T orElse) → T
Checks if the list has only one element, and returns that element. Return null if the list is empty or has more than one element.
inherited
singleWhere(Predicate<T> test, {T orElse()?}) → T
Returns the single element that satisfies test.
inherited
skip(int count) Iterable<T>
Returns an Iterable that provides all but the first count elements.
inherited
skipWhile(bool test(T value)) Iterable<T>
Returns an Iterable that skips leading elements while test is satisfied.
inherited
sort([int compare(T a, T b)?]) IList<T>
Sorts this list according to the order specified by the compare function.
inherited
sortLike(Iterable<T> ordering) IList<T>
Sorts this list according to the order specified by the ordering iterable. Items which don't appear in ordering will be included in the end, in no particular order.
inherited
sortOrdered([int compare(T a, T b)?]) IList<T>
Sorts this list according to the order specified by the compare function.
inherited
sortReversed([int compare(T a, T b)?]) IList<T>
Sorts this list in reverse order in relation to the default sort method.
inherited
span(Predicate<T> p) Tuple2<Iterable<T>, Iterable<T>>
Split list based on predicate p. (takeWhile p, dropWhile p)
inherited
splitAt(int index) Tuple2<Iterable<T>, Iterable<T>>
Split the List at specified index
inherited
sublist(int start, [int? end]) IList<T>
Returns a new list containing the elements between start and end.
inherited
tails() Iterable<Iterable<T>>
inherited
take(int count) Iterable<T>
Returns an Iterable of the count first elements of this iterable.
inherited
takeWhile(bool test(T value)) Iterable<T>
Returns an Iterable of the leading elements satisfying test.
inherited
toggle(T element) IList<T>
Removes the first instance of the element, if it exists in the list. Otherwise, adds it to the list.
inherited
toJson(Object? toJsonT(T)) Object
Converts to JSon. Json serialization support for json_serializable with @JsonSerializable.
inherited
toList({bool growable = true}) List<T>
Creates a List containing the elements of this IList.
inherited
toSet() Set<T>
Creates a Set containing the same elements as this IList.
inherited
toString([bool? prettyPrint]) String
Returns a string representation of (some of) the elements of this.
inherited
unorderedEqualItems(covariant Iterable? other) bool
Will return true only if the IList and the iterable items have the same number of elements, and the elements of the IList can be paired with the elements of the iterable, so that each pair is equal. This may be slow for very large lists, since it compares each item, one by one.
inherited
updateById(Iterable<T> newItems, dynamic id(T item)) IList<T>
Returns a new list where newItems are added or updated, by their id (and the id is a function of the item), like so:
inherited
where(Predicate<T> test) Iterable<T>
Returns an Iterable with all elements that satisfy the predicate test.
inherited
whereMoveToTheEnd(bool test(T item)) IList<T>
Moves all items that satisfy the provided test to the end of the list. Keeps the relative order of the moved items.
inherited
whereMoveToTheStart(bool test(T item)) IList<T>
Moves all items that satisfy the provided test to the start of the list. Keeps the relative order of the moved items.
inherited
whereNot(Predicate<T> test) Iterable<T>
Returns an Iterable with all elements that doest NOT satisfy the predicate test.
inherited
whereType<E>() Iterable<E>
Returns an Iterable with all elements that have type E.
inherited
withConfig(ConfigList config) IList<T>
Creates a new list with the given config.
inherited
withConfigFrom(IList<T> other) IList<T>
Returns a new list with the contents of the present IList, but the config of other.
inherited
zip(Iterable<T> otherIterable) Iterable<Tuple2<T, T>>
Aggregate two sources trimming by the shortest source
inherited
zipAll<U>(Iterable<U> otherIterable, {T currentFill(int index)?, U otherFill(int index)?}) Iterable<Tuple2<T?, U?>>
Aggregate two sources based on the longest source. Missing elements can be completed by passing a currentFill and otherFill methods or will be at null by default
inherited
zipWithIndex() Iterable<Tuple2<int, T>>
Aggregate each element with corresponding index
inherited

Operators

operator +(Iterable<T> other) IList<T>
Returns the concatenation of this list and other. Returns a new list containing the elements of this list followed by the elements of other.
inherited
operator ==(Object other) bool
  • If isDeepEquals configuration is true: Will return true only if the list items are equal (and in the same order), and the list configurations are equal. This may be slow for very large lists, since it compares each item, one by one.

  • If isDeepEquals configuration is false: Will return true only if the lists internals are the same instances (comparing by identity). This will be fast even for very large lists, since it doesn't compare each item.

  • inherited
    operator [](int index) → T
    Returns the object at the given index in the list or throws a RangeError if index is out of bounds.
    inherited