lastIndex property

int? get lastIndex

Returns the last accessible index. If collection is empty this returns null.

Example:

var list = ['a', 'b', 'c'];
list.lastIndex; // 2
list[list.lastIndex]; // 'c'

Implementation

int? get lastIndex {
  if (isNotEmpty) {
    return length - 1;
  } else {
    return null;
  }
}