firstOrNull property

E? get firstOrNull

First element or null if the collection is empty.

var first = [1, 2, 3, 4].firstOrNull; // 1
var emptyFirst = [].firstOrNull; // null

Implementation

E? get firstOrNull => elementAtOrNull(0);