cell<V> method

Cell cell<V>(
  1. Symbol id
)

Returns the cell registered at id, narrowed to ValueCell<V> when the registration is a ValueCell.

Parameters:

  • id: The Registration Key. The Symbol used at add.

Returns:

The registered Cell. If the registration is a ValueCell<V>, the result is narrowed to that type; plain Cell registrations are returned as-is.

Throws:

  • StateError when id is not registered.
  • StateError when the registration is a ValueCell whose value type does not satisfy V.

See Also:

  • valueCell — the variant that requires a ValueCell<V>.
  • CellScope.of — the production equivalent with the same semantics.

Implementation

Cell cell<V>(Symbol id) {
  final c = _cells[id];
  if (c == null) {
    throw StateError('CellTestHarness: no cell registered at $id.');
  }
  if (c is ValueCell && c is! ValueCell<V>) {
    throw StateError(
      'CellTestHarness: $id is ${c.runtimeType}, not ValueCell<$V>.',
    );
  }
  return c;
}