FicListExtension<T> extension

on

Properties

lock IList<T>
Locks the list, returning an immutable list (IList).
no setter
lockUnsafe IList<T>
Locks the list, returning an immutable list (IList).
no setter
reversedView List<T>
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

Methods

addBetween(T separator) List<T>
Return a new list, adding a separator between the original list items (but not before the first and after the last).
compareAsSets(List other) bool
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>
Return an efficient concatenation of up to 5 lists:
distinct({dynamic by(T item)?}) List<T>
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>>
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>>
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.
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.
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.
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.
moveToTheEnd(T item) → void
Moves the first occurrence of the item to the end of the list.
moveToTheFront(T item) → void
Moves the first occurrence of the item to the start of the list.
removeDuplicates({dynamic by(T item)?, bool removeNulls = false}) → void
Removes all duplicates from the list, leaving only the distinct items. Optionally, you can provide an id function to compare the items.
removeNulls() → void
Removes all nulls from the List.
sortLike(Iterable ordering) → void
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
Sorts this list according to the order specified by the compare function.
sortReversed([int compare(T a, T b)?]) → void
Sorts this list in reverse order in relation to the default sort method.
splitByLength(int length) List<List<T>>
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>>
Split a list, according to a predicate, removing the list item that satisfies the predicate.
toggle(T item) bool
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.
whereMoveToTheEnd(bool test(T item)) → void
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
Moves all items that satisfy the provided test to the start of the list. Keeps the relative order of the moved items.