lastOrNull method

T? lastOrNull()

Consumes the iterator and returns the last element.

Implementation

T? lastOrNull() {
  if (moveNext()) {
    var last = current;
    while (moveNext()) {
      last = current;
    }
    return last;
  }
  return null;
}