whenReady property

ValueCell<T> get whenReady

Create a cell that evaluates to ValueCell.none() while the cell's value is uninitialized.

The returned cell evaluates to ValueCell.none(), when this cell throws an UninitializedCellError, PendingAsyncValueError or EmptyMetaCellError

Implementation

ValueCell<T> get whenReady => ComputeCell(
  key: _WhenReadyKey(this),
  arguments: {this},
  compute: () {
    try {
      return value;
    }
    on UninitializedCellError {
      return ValueCell.none();
    }
    on PendingAsyncValueError {
      return ValueCell.none();
    }
    on EmptyMetaCellError{
      return ValueCell.none();
    }
  },
);