takeOrNull method

T? takeOrNull()

Takes the value out of this OnceCell, moving it back to an uninitialized state. Returns null if the cell is empty.

Implementation

T? takeOrNull() {
  if (_isSet) {
    _isSet = false;
    final val = _val;
    _val = null;
    return val;
  }
  return null;
}