description

# elementAtOrNull method

T? elementAtOrNull(

1. int index

)

The element at position `index` of this iterable, or `null`.

The `index` is zero based, and must be non-negative.

Returns the result of `elementAt(index)` if the iterable has at least `index + 1` elements, and `null` otherwise.

## Implementation

    T? elementAtOrNull(int index) {
      RangeError.checkNotNegative(index, "index");
      if (this is EfficientLengthIterable) {
        if (index >= length) return null;
        return elementAt(index);
      }
      var iterator = this.iterator;
      do {
        if (!iterator.moveNext()) return null;
      } while (--index >= 0);
      return iterator.current;
    }