lastOrNull property

T? lastOrNull

get the last element if the list is not empty or return null

Implementation

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