penultimate property

T? get penultimate

Returns the second-to-last element, or null if the list has fewer than 2 items.

Implementation

T? get penultimate => length >= 2 ? this[length - 2] : null;