firstOrNull property

T? get firstOrNull

Returns the first element of the iterable or null if empty or null.

Example:

Iterable<int>? numbers = [1, 2, 3];
int? result = numbers.firstOrNull;  // 1

Implementation

T? get firstOrNull => isNullOrEmpty ? null : this!.first;