lastOrNull property

E? lastOrNull

Returns the last element, or null if the collection is empty.

Implementation

E? get lastOrNull => isEmpty ? null : last;