takeOrOption method

Option<T> takeOrOption()

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

Implementation

Option<T> takeOrOption() {
  if (_isSet) {
    _isSet = false;
    final val = _val;
    _val = null;
    return Some(val as T);
  }
  return None;
}