firstOrNull method
T
firstOrNull()
Returns the first element. If there is no first element it will
return null
.
Example:
['a', 'b'].firstOrNull(); // 'a'
[].firstOrNull(); // null
Implementation
T firstOrNull() {
return firstOrElse(() => null as T);
}