ListUtils<T> extension

A collection of useful List extensions to simplify common operations.

on

Methods

chunked({required int size}) List<List<T>>

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

Splits the list into chunks of size size.
elementAtOrNull({required int index}) → T?

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

Safely returns the element at index, or null if out of range.
groupBy<K>(K keySelector(T)) Map<K, List<T>>

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

Groups list items by a key returned from keySelector.
mapNotNull<R>(R? transform(T)) List<R>

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

Maps each element using transform and removes null results.
sortIt<R extends Comparable>([R selector(T)?]) List<T>

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

Returns a new list sorted by the value produced by selector.
sortItDesc<R extends Comparable>([R selector(T)?]) List<T>

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

Returns a new list sorted in descending order based on selector.
sortItSelf<R extends Comparable>([R selector(T)?]) → void

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

Sorts this list in-place using the value returned by selector.
sortItSelfDesc<R extends Comparable>([R selector(T)?]) → void

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

Sorts this list in-place in descending order.