getAndMap method

T getAndMap(
  1. int index,
  2. T map(
    1. int index,
    2. bool inRange,
    3. T? value
    )
)

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.

Implementation

T getAndMap(
  int index,
  T Function(int index, bool inRange, T? value) map,
) {
  bool inRange = (index >= 0 && index < _l.length);

  T? value = inRange ? _l[index] : null;
  return map(index, inRange, value);
}