previous<V> function

V? previous<V>(
  1. List<V> list,
  2. int index
)

Returns a preceding element in the index, if out of bounds returns null.

Implementation

V? previous<V>(List<V> list, int index) {
  return index == 0 ? null : list[index - 1];
}