lastOrNullSC method

  1. @Deprecated('Dart natively supports this function. Read DartDoc comment for more info.')
T? lastOrNullSC()

Deprecation hint: Read the migration guide for more details on migrating.

Returns the last element. If there is no last element it will return null.

Example:

['a', 'b'].lastOrElse(); // 'a'
[].lastOrElse();         // null

Implementation

@Deprecated(
    'Dart natively supports this function. Read DartDoc comment for more info.')
T? lastOrNullSC() {
  if (isEmpty) {
    return null;
  }

  return lastWhere((_) => true, orElse: null);
}