ModifiableListFromIList<T> class

The ModifiableListFromIList is a safe, modifiable List that is built from an IList. The construction of the list is fast at first, since it makes no copies of the IList items, but just uses it directly.

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.

See also: UnmodifiableListFromIList

Implemented types
Mixed-in types
Available extensions

Constructors

ModifiableListFromIList.new(IList<T>? ilist)

Properties

asComparableEntries Iterable<Entry<K, V>>

Available on Iterable<MapEntry<K, V>>, provided by the FicIterableOfMapEntryExtension extension

MapEntry is not Comparable. If you need to compare two iterables of MapEntry you can do this:
no setter
first ↔ T
The first element.
getter/setter pairinherited
firstOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The first element of this iterator, or null if the iterable is empty.
no setter
hashCode int
The hash code for this object.
no setterinherited
indexed Iterable<(int, T)>

Available on Iterable<T>, provided by the IterableExtensions extension

Pairs of elements of the indices and elements of this iterable.
no setter
isEmpty bool
Whether this collection has no elements.
no setterinherited
isNotEmpty bool
Whether this collection has at least one element.
no setterinherited
iterator Iterator<T>
A new Iterator that allows iterating the elements of this Iterable.
no setterinherited
last ↔ T
The last element.
getter/setter pairinherited
lastOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The last element of this iterable, or null if the iterable is empty.
no setter
length int
The number of objects in this list.
getter/setter pairoverride
lock IList<T>
Locks the list, returning an immutable list (IList).
no setter
lock IList<T>

Available on List<T>, provided by the FicListExtension extension

Locks the list, returning an immutable list (IList).
no setter
lockUnsafe IList<T>

Available on List<T>, provided by the FicListExtension extension

Locks the list, returning an immutable list (IList).
no setter
nonNulls Iterable<T>

Available on Iterable<T?>, provided by the NullableIterableExtensions extension

The non-null elements of this iterable.
no setter
reversed Iterable<T>
An Iterable of the objects in this list in reverse order.
no setterinherited
reversedView List<T>

Available on List<T>, provided by the FicListExtension extension

Returns a List of the objects in this list in reverse order. Very efficient since it returns a view (which means, if you change the original list this one will also change, and vice-versa).
no setter
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.
no setterinherited
singleOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The single element of this iterator, or null.
no setter
toJS JSArray<T>

Available on List<T>, provided by the ListToJSArray extension

Converts this List to a JSArray by either casting, unwrapping, or cloning the List.
no setter
toJSProxyOrRef JSArray<T>

Available on List<T>, provided by the ListToJSArray extension

Converts this List to a JSArray by either casting, unwrapping, or proxying the List.
no setter
wait Future<List<T>>

Available on Iterable<Future<T>>, provided by the FutureIterable extension

Waits for futures in parallel.
no setter

Methods

add(T value) → void
Adds value to the end of this list, extending the length by one.
override
addAll(Iterable<T> values) → void
Appends all objects of iterable to the end of this list.
override
addBetween(T separator) List<T>

Available on List<T>, provided by the FicListExtension extension

Return a new list, adding a separator between the original list items (but not before the first and after the last).
any(bool test(T element)) bool
Checks whether any element of this iterable satisfies test.
inherited
anyIs(T value) bool

Available on Iterable<T>, provided by the FicIterableExtension extension

Returns true if any item is equal to value.
asList() List<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

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.
asMap() Map<int, T>
An unmodifiable Map view of this list.
inherited
asNameMap() Map<String, T>

Available on Iterable<T>, provided by the EnumByName extension

Creates a map from the names of enum values to the values.
asSet() Set<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

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

Available on Iterable<T>, provided by the FicIterableExtension extension

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:
byName(String name) → T

Available on Iterable<T>, provided by the EnumByName extension

Finds the enum value in this list with name name.
cast<R>() List<R>
Returns a view of this list as a list of R instances.
inherited
clear() → void
Removes all objects from this list; the length of the list becomes zero.
inherited
compareAsSets(List other) bool

Available on List<T>, provided by the FicListExtension extension

Return true if the lists contain the same items (in any order). Ignores repeated items.
concat(List<T>? list2, [List<T>? list3, List<T>? list4, List<T>? list5]) List<T>

Available on List<T>, provided by the FicListExtension extension

Return an efficient concatenation of up to 5 lists:
contains(Object? element) bool
Whether the collection contains an element equal to element.
inherited
deepEquals(Iterable? other, {bool ignoreOrder = false}) bool

Available on Iterable<T>, provided by the FicIterableExtension extension

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

Available on Iterable<T>, provided by the FicIterableExtension extension

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.
distinct({dynamic by(T item)?}) List<T>

Available on List<T>, provided by the FicListExtension extension

Returns a new list, which is equal to the original one, but without duplicates. In other words, the new list has only distinct items. Optionally, you can provide an id function to compare the items.
divideList(Predicate<T> test) List<List<T>>

Available on List<T>, provided by the FicListExtension extension

Search a list for items that satisfy a test predicate (matching items), and then divide that list into parts, such as each part contains one matching item. Except maybe for the first matching item, it will keep the matching items as the first item in each part.
divideListAsMap<G>(bool test(T item), {G key(T item)?, bool includeFirstItems = false}) Map<G, List<T>>

Available on List<T>, provided by the FicListExtension extension

Search a list for items that satisfy a test predicate (matching items), and then divide that list into a Map of parts, such as each part contains one matching item, and the keys are given by the key function.
elementAt(int index) → T
Returns the indexth element.
inherited
elementAtOrNull(int index) → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The element at position index of this iterable, or null.
every(bool test(T element)) bool
Checks whether every element of this iterable satisfies test.
inherited
everyIs(T value) bool

Available on Iterable<T>, provided by the FicIterableExtension extension

Returns true if all items are equal to value.
expand<T>(Iterable<T> f(T element)) Iterable<T>
Expands each element of this Iterable into zero or more elements.
inherited
fillRange(int start, int end, [T? fill]) → void
Overwrites a range of elements with fillValue.
inherited
findDuplicates() Set<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

Finds duplicates and then returns a Set with the duplicated elements. If there are no duplicates, an empty Set is returned.
firstWhere(bool test(T element), {T orElse()?}) → T
The first element that satisfies the given predicate test.
inherited
fold<T>(T initialValue, T combine(T previousValue, T element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(Iterable<T> other) Iterable<T>
Creates the lazy concatenation of this iterable and other.
inherited
forEach(void action(T element)) → void
Invokes action on each element of this iterable in iteration order.
inherited
get(int index, {T orElse(int index)?}) → T

Available on List<T>, provided by the FicListExtension extension

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.
getAndMap(int index, T map(int index, bool inRange, T? value)) → T

Available on List<T>, provided by the FicListExtension extension

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.
getOrNull(int index) → T?

Available on List<T>, provided by the FicListExtension extension

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.
getRange(int start, int end) Iterable<T>
Creates an Iterable that iterates over a range of elements.
inherited
indexOf(Object? element, [int start = 0]) int
The first index of element in this list.
inherited
indexWhere(bool test(T element), [int start = 0]) int
The first index in the list that satisfies the provided test.
inherited
insert(int index, T element) → void
Inserts element at position index in this list.
inherited
insertAll(int index, Iterable<T> iterable) → void
Inserts all objects of iterable at position index in this list.
inherited
isFirst(T item) bool

Available on Iterable<T>, provided by the FicIterableExtension extension

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

Available on Iterable<T>, provided by the FicIterableExtension extension

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

Available on Iterable<T>, provided by the FicIterableExtension extension

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

Available on Iterable<T>, provided by the FicIterableExtension extension

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:
join([String separator = ""]) String
Converts each element to a String and concatenates the strings.
inherited
lastIndexOf(Object? element, [int? start]) int
The last index of element in this list.
inherited
lastIndexWhere(bool test(T element), [int? start]) int
The last index in the list that satisfies the provided test.
inherited
lastWhere(bool test(T element), {T orElse()?}) → T
The last element that satisfies the given predicate test.
inherited
map<T>(T f(T element)) Iterable<T>
The current elements of this iterable modified by toElement.
inherited
mapIndexedAndLast<R>(R convert(int index, T item, bool isLast)) Iterable<R>

Available on Iterable<T>, provided by the FicIterableExtension extension

Maps each element and its index to a new value. This is similar to mapIndexed but also tells you which item is the last.
mapNotNull<E>(E? f(T? e)) Iterable<E>

Available on Iterable<T?>, provided by the FicIterableExtensionTypeNullable extension

Similar to map, but MAY return a non-nullable type.
moveToTheEnd(T item) → void

Available on List<T>, provided by the FicListExtension extension

Moves the first occurrence of the item to the end of the list.
moveToTheFront(T item) → void

Available on List<T>, provided by the FicListExtension extension

Moves the first occurrence of the item to the start of the list.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reduce(T combine(T previousValue, T element)) → T
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
remove(Object? element) bool
Removes the first occurrence of value from this list.
inherited
removeAt(int index) → T
Removes the object at position index from this list.
inherited
removeDuplicates({dynamic by(T item)?, bool removeNulls = false}) → void

Available on List<T>, provided by the FicListExtension extension

Removes all duplicates from the list, leaving only the distinct items. Optionally, you can provide an id function to compare the items.
removeLast() → T
Removes and returns the last object in this list.
inherited
removeNulls() → void

Available on List<T>, provided by the FicListExtension extension

Removes all nulls from the List.
removeRange(int start, int end) → void
Removes a range of elements from the list.
inherited
removeWhere(bool test(T element)) → void
Removes all objects from this list that satisfy test.
inherited
replaceRange(int start, int end, Iterable<T> newContents) → void
Replaces a range of elements with the elements of replacements.
inherited
restrict(T? item, {required T orElse}) → T

Available on Iterable<T>, provided by the FicIterableExtension extension

Restricts some item to one of those present in this iterable.
retainWhere(bool test(T element)) → void
Removes all objects from this list that fail to satisfy test.
inherited
setAll(int index, Iterable<T> iterable) → void
Overwrites elements with the objects of iterable.
inherited
setRange(int start, int end, Iterable<T> iterable, [int skipCount = 0]) → void
Writes some elements of iterable into a range of this list.
inherited
shuffle([Random? random]) → void
Shuffles the elements of this list randomly.
inherited
singleWhere(bool test(T element), {T orElse()?}) → T
The single element that satisfies test.
inherited
skip(int count) Iterable<T>
Creates an Iterable that provides all but the first count elements.
inherited
skipWhile(bool test(T element)) Iterable<T>
Creates an Iterable that skips leading elements while test is satisfied.
inherited
sort([int compare(T a, T b)?]) → void
Sorts this list according to the order specified by the compare function.
inherited
sortedLike(Iterable ordering) List<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

Returns a list, sorted according to the order specified by the ordering iterable. Items which don't appear in ordering will be included in the end, in their original order. Items of ordering which are not found in the original list are ignored.
sortedReversed([Comparator<T>? compare]) List<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

Creates a reversed sorted list of the elements of the iterable.
sortLike(Iterable ordering) → void

Available on List<T>, provided by the FicListExtension extension

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 their original order. Items of ordering which are not found in the original list are ignored.
sortOrdered([int compare(T a, T b)?]) → void

Available on List<T>, provided by the FicListExtension extension

Sorts this list according to the order specified by the compare function.
sortReversed([int compare(T a, T b)?]) → void

Available on List<T>, provided by the FicListExtension extension

Sorts this list in reverse order in relation to the default sort method.
splitByLength(int length) List<List<T>>

Available on List<T>, provided by the FicListExtension extension

Cut the original list into one or more lists with at most length items.
splitList(bool test(T item), {bool emptyParts = false}) Iterable<List<T>>

Available on List<T>, provided by the FicListExtension extension

Split a list, according to a predicate, removing the list item that satisfies the predicate.
sublist(int start, [int? end]) List<T>
Returns a new list containing the elements between start and end.
inherited
sumBy<N extends num>(N mapper(T element)) → N

Available on Iterable<T>, provided by the FicIterableExtension extension

The sum of the values returned by the mapper function.
take(int count) Iterable<T>
Creates a lazy iterable of the count first elements of this iterable.
inherited
takeWhile(bool test(T element)) Iterable<T>
Creates a lazy iterable of the leading elements satisfying test.
inherited
toggle(T item) bool

Available on List<T>, provided by the FicListExtension extension

If the item does not exist in the list, add it and return true. If it already exists, remove the first instance of it and return false.
toIList([ConfigList? config]) IList<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

Creates an immutable list (IList) from the iterable.
toISet([ConfigSet? config]) ISet<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

Creates an immutable set (ISet) from the iterable.
toList({bool growable = true}) List<T>
Creates a List containing the elements of this Iterable.
inherited
toSet() Set<T>
Creates a Set containing the same elements as this iterable.
inherited
toString() String
A string representation of this object.
inherited
unzip() Tuple2<Iterable<U>, Iterable<V>>

Available on Iterable<Tuple2<U, V>>, provided by the FICZipExtension extension

Iterable Tuple2 as Iterable
updateById(Iterable<T> newItems, dynamic id(T item)) List<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

Returns a new list where newItems are added or updated, by their id (and the id is a function of the item), like so:
where(bool test(T element)) Iterable<T>
Creates a new lazy Iterable with all elements that satisfy the predicate test.
inherited
whereMoveToTheEnd(bool test(T item)) → void

Available on List<T>, provided by the FicListExtension extension

Moves all items that satisfy the provided test to the end of the list. Keeps the relative order of the moved items.
whereMoveToTheFront(bool test(T item)) → void

Available on List<T>, provided by the FicListExtension extension

Moves all items that satisfy the provided test to the start of the list. Keeps the relative order of the moved items.
whereNoDuplicates({dynamic by(T item)?, bool removeNulls = false}) Iterable<T>

Available on Iterable<T>, provided by the FicIterableExtension extension

Removes all duplicates, leaving only the distinct items. Optionally, you can provide an by function to compare the items.
whereType<T>() Iterable<T>
Creates a new lazy Iterable with all elements that have type T.
inherited
withNullsRemoved() List<T>

Available on List<T?>, provided by the FicListExtensionNullable extension

Returns a new List with all nulls removed. This may return a list with a non-nullable type.

Operators

operator +(List<T> other) List<T>
Returns the concatenation of this list and other.
inherited
operator ==(Object other) bool
The equality operator.
inherited
operator [](int index) → T
The object at the given index in the list.
override
operator []=(int index, T value) → void
Sets the value at the given index in the list to value.
override