safe_lodash library

Support for doing something awesome.

More dartdocs go here.

Functions

chunk<T>(List<T> list, [int size = 1]) List<List<T>>
Creates an List of elements split into groups the length of size. If List can't be split evenly, the final chunk will be the remaining elements.
compact<T>(List<T?> list) List<T>
Creates a list with all falsey values removed. The values false, null, 0, "", and NaN are falsey.
concat(List list, [List? values]) List
Creates a new list concatenating list with any additional lists and/or values.
difference<T>(List<T> list, List<List<T>> values) List<T>
Creates a list of list values not included in the other given lists.
differenceBy<T, R>(List<T> list, List<List<T>> values, R iteratee(T)) List<T>
This method is like difference except that it accepts iteratee which is invoked for each element of list and values to generate the criterion by which they're compared.
differenceWith<T>(List<T> list, List<List<T>> values, bool comparator(T, T)) List<T>
This method is like difference except that it accepts comparator which is invoked to compare elements of list to values.
drop<T>(List<T> list, [int n = 1]) List<T>
Creates a slice of list with n elements dropped from the beginning.
dropRight<T>(List<T> list, [int n = 1]) List<T>
Creates a slice of list with n elements dropped from the end.
dropRightWhile<T>(List<T> list, bool predicate(T)) List<T>
Creates a slice of list excluding elements dropped from the end. Elements are dropped until predicate returns falsey.
dropWhile<T>(List<T> list, bool predicate(T)) List<T>
Creates a slice of list excluding elements dropped from the beginning. Elements are dropped until predicate returns falsey.
fill(List list, dynamic value, [int start = 0, int? end]) List
Fills elements of list with value from start up to, but not including, end.
findIndex<T>(List<T> list, bool predicate(T), [int fromIndex = 0]) int
This method is like find except that it returns the index of the first element predicate returns truthy for instead of the element itself.
findLastIndex<T>(List<T> list, bool predicate(T), [int? fromIndex]) int
This method is like findIndex except that it iterates over elements of collection from right to left.
first<T>(List<T> list) → T?
Alias for head
flatten(List list) List
Flattens list a single level deep.
flattenDeep(List list) List
Recursively flattens list.
flattenDepth(List list, [int depth = 1]) List
Recursively flatten list up to depth times.
fromPairs<K, V>(List<List> pairs) Map<K, V>
The inverse of toPairs; this method returns an object composed from key-value pairs.
Gets the first element of list.
indexOf<T>(List<T> list, T value, [int fromIndex = 0]) int
Gets the index at which the first occurrence of value is found in list.
initial<T>(List<T> list) List<T>
Gets all but the last element of list.
intersection<T>(List<List<T>> lists) List<T>
Creates a list of unique values that are included in all given lists.
intersectionBy<T, R>(List<List<T>> lists, R iteratee(T)) List<T>
This method is like intersection except that it accepts iteratee which is invoked for each element of each lists to generate the criterion by which they're compared.
intersectionWith<T>(List<List<T>> lists, bool comparator(T, T)) List<T>
This method is like intersection except that it accepts comparator which is invoked to compare elements of lists.
join(List list, [String separator = ',']) String
Converts all elements in list into a string separated by separator.
last<T>(List<T> list) → T?
Gets the last element of list.
lastIndexOf<T>(List<T> list, T value, [int? fromIndex]) int
This method is like indexOf except that it iterates over elements of list from right to left.
nth<T>(List<T> list, [int n = 0]) → T?
Gets the element at index n of list. If n is negative, the nth element from the end is returned.
pull<T>(List<T> list, List<T> values) List<T>
Removes all given values from list.
pullAll<T>(List<T> list, List<T> values) List<T>
This method is like pull except that it accepts an array of values to remove.
pullAllBy<T, R>(List<T> list, List<T> values, R iteratee(T)) List<T>
This method is like pullAll except that it accepts iteratee which is invoked for each element of list and values to generate the criterion by which they're compared.
pullAllWith<T>(List<T> list, List<T> values, bool comparator(T, T)) List<T>
This method is like pullAll except that it accepts comparator which is invoked to compare elements of list to values.
pullAt<T>(List<T> list, List<int> indexes) List<T>
Removes elements from list corresponding to indexes and returns a list of removed elements.
remove<T>(List<T> list, bool predicate(T)) List<T>
Removes all elements from list that predicate returns truthy for and returns a list of the removed elements.
reverse<T>(List<T> list) List<T>
Reverses list so that the first element becomes the last, the second element becomes the second to last, and so on.
slice<T>(List<T> list, [int start = 0, int? end]) List<T>
Creates a slice of List from start up to, but not including, end.
sortedIndex<T extends Comparable>(List<T> list, T value) int
Uses a binary search to determine the lowest index at which value should be inserted into list in order to maintain its sort order.
sortedIndexBy<T, R extends Comparable>(List<T> list, T value, R iteratee(T)) int
This method is like sortedIndex except that it accepts iteratee which is invoked for value and each element of list to compute their sort ranking.
sortedIndexOf<T>(List<T> list, T value) int
This method is like indexOf except that it performs a binary search on a sorted list.
sortedLastIndex<T extends Comparable>(List<T> list, T value) int
This method is like sortedIndex except that it returns the highest index at which value should be inserted into list in order to maintain its sort order.
sortedLastIndexBy<T, R extends Comparable>(List<T> list, T value, R iteratee(T)) int
This method is like sortedLastIndex except that it accepts iteratee which is invoked for value and each element of list to compute their sort ranking.
sortedLastIndexOf<T>(List<T> list, T value) int
This method is like lastIndexOf except that it performs a binary search on a sorted list.
sortedUniq<T>(List<T> list) List<T>
This method is like uniq except that it's designed and optimized for sorted lists.
sortedUniqBy<T, R>(List<T> list, R iteratee(T)) List<T>
This method is like uniqBy except that it's designed and optimized for sorted lists.
tail<T>(List<T> list) List<T>
Gets all but the first element of list.
take<T>(List<T> list, [int n = 1]) List<T>
Creates a slice of list with n elements taken from the beginning.
takeRight<T>(List<T> list, [int n = 1]) List<T>
Creates a slice of list with n elements taken from the end.
takeRightWhile<T>(List<T> list, bool predicate(T)) List<T>
Creates a slice of list with elements taken from the end. Elements are taken until predicate returns falsey.
takeWhile<T>(List<T> list, bool predicate(T)) List<T>
Creates a slice of list with elements taken from the beginning. Elements are taken until predicate returns falsey.
toPairs(Map map) List<List>
Creates a list of key-value pairs from an object.
union<T>(List<List<T>> lists) List<T>
Creates a list of unique values, in order, from all given lists.
unionBy<T, R>(List<List<T>> lists, R iteratee(T)) List<T>
This method is like union except that it accepts iteratee which is invoked for each element of each lists to generate the criterion by which uniqueness is computed.
unionWith<T>(List<List<T>> lists, bool comparator(T, T)) List<T>
This method is like union except that it accepts comparator which is invoked to compare elements of lists.
uniq<T>(List<T> list) List<T>
Creates a duplicate-free version of a list, using == for equality comparisons, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the list.
uniqBy<T, R>(List<T> list, R iteratee(T)) List<T>
This method is like uniq except that it accepts iteratee which is invoked for each element in list to generate the criterion by which uniqueness is computed.
uniqWith<T>(List<T> list, bool comparator(T, T)) List<T>
This method is like uniq except that it accepts comparator which is invoked to compare elements of list.
unzip(List<List> list) List<List>
This method is like zip except that it accepts a list of grouped elements and creates a list regrouping the elements to their pre-zip configuration.
unzipWith<R>(List<List> list, R iteratee(List)) List<R>
This method is like unzip except that it accepts iteratee to specify how regrouped values should be combined.
without<T>(List<T> list, List<T> values) List<T>
Creates a list excluding all given values.
xor<T>(List<List<T>> lists) List<T>
Creates a list of unique values that is the symmetric difference of the given lists.
xorBy<T, R>(List<List<T>> lists, R iteratee(T)) List<T>
This method is like xor except that it accepts iteratee which is invoked for each element of each lists to generate the criterion by which by which they're compared.
xorWith<T>(List<List<T>> lists, bool comparator(T, T)) List<T>
This method is like xor except that it accepts comparator which is invoked to compare elements of lists.
zip(List<List> lists) List<List>
Creates a list of grouped elements, the first of which contains the first elements of the given lists, the second of which contains the second elements of the given lists, and so on.
zipObject(List props, [List? values]) Map
This method is like fromPairs except that it accepts two lists, one of property identifiers and one of corresponding values.
zipWith<R>(List<List> lists, R iteratee(List)) List<R>
This method is like zip except that it accepts iteratee to specify how grouped values should be combined.