firstOrNullSC method
- @Deprecated('Dart natively supports this function. Read DartDoc comment for more info.')
Deprecation hint: Read the migration guide for more details on migrating.
Returns the first element.
If there is no first element it will return null
.
Example:
['a', 'b'].firstOrNull(); // 'a'
[].firstOrNull(); // null
Implementation
@Deprecated(
'Dart natively supports this function. Read DartDoc comment for more info.')
T? firstOrNullSC() {
if (isEmpty) {
return null;
}
return firstWhere((_) => true, orElse: null);
}