lastOrNull property

T? get lastOrNull

Returns null instead of throwing if the list is empty.

Implementation

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