ListExtension<T> extension

List extension to extend List functionality

on

Properties

avg num
Get average of numbers
no setter
flatten List<T>
Merge list of lists into single list
no setter
max → T
Get maximum number
no setter
median num
Get median of numbers
no setter
min → T
Get minimum number
no setter
mode num
Get mode of numbers
no setter
random → T
Returns random value from this list
no setter
sortedDesc List<T>
Get sorted list
no setter
sum num
Get sum of numbers
no setter
whereNumbers List<num>
Get numbers from a list
no setter

Methods

chunk(int size) List<List<T>>
The chunk method breaks the list into multiple, smaller list of a given size
groupBy(T fn(T)) Map<T, List<T>>
Group by objects according to condition
groupByKey(String key) Map<T, List<T>>
Group the objects according to key
hasKey(String key) bool
Checks if the given key exists in the map.
hasKeyValue(String key, T value) bool
Checks given key/value is exists or not
hasValue(T value) bool
Checks if the given value exists in the map.
latest([String key = 'id']) List<Map<T, T>>
The latest methods allow you to easily order results by id in descending. By default, the result will be ordered by the id field. Or, you may pass the key that you wish to sort by:
latestFirst([String key = 'id']) Map<T, T>
The latestFirst methods allow you to easily order results by id in descending order and get first record. By default, the result will be ordered by the id field. Or, you may pass the key that you wish to sort by:
oldest([String key = 'id']) List<Map<T, T>>
The oldest methods allow you to easily order results by id. By default, the result will be ordered by the id field. Or, you may pass the column name that you wish to sort by:
oldestFirst([String key = 'id']) Map<T, T>
The oldestFirst methods allow you to easily order results by id and get first record. By default, the result will be ordered by the id field. Or, you may pass the column name that you wish to sort by:
pluck(String key) List<T?>
The pluck method retrieves all of the values for a given key
sortBy(String key, {bool isDesc = false}) List<Map<T, T>>
The sortBy method sorts the list of maps by the given key.
sortDescBy(String key) List<Map<T, T>>
The sortDescBy method sorts the list of objects by the given key.
sorted({bool isDesc = false}) List<T>
Get sorted list
split(int parts) List<List<T>>
The split method breaks the list into equal sized lists of a given size
whereBetween(String key, num start, num end) List<T>
Filters the collection by determining if a specified item value is within a given range
whereIn(String key, List<num> params) List<T>
Removes elements from the list that do not have a specified item value
whereNotBetween(String key, num start, num end) List<T>
Filters the collection by determining if a specified item value is outside of a given range
whereNotIn(String key, List<num> params) List<T>
Removes elements from the list that have a specified item value
whereNotOnly(List<String> keys) List<T>
Removes elements from the list which is given
whereOnly(List<String> keys) List<T>
Gets only those values which is given