valueOf<V> static method

ValueCell<V> valueOf<V>(
  1. BuildContext context,
  2. Symbol id
)

Returns the cell registered at id, narrowed to ValueCell<V>.

This is the common lookup for CellBuilder: Cell.state returns a ValueCell internally, and most app-level registrations are ValueCells. Registrations that are not ValueCell<V> throw — use of for plain Cell sources (Cell.derive, Cell.asyncMap, Cell.ingress, cell_tissue collections).

Parameters:

  • context: The Lookup Context.
  • id: The Registration Key.

Returns:

The registered cell, statically typed as ValueCell<V>.

Throws:

  • All the conditions under which of throws.
  • StateError when the registration is a ValueCell whose value type does not satisfy V, or when the registration is not a ValueCell at all.

See Also:

  • of — the un-narrowed lookup for any Cell.

Implementation

static ValueCell<V> valueOf<V>(BuildContext context, Symbol id) {
  final cell = of<V>(context, id);
  if (cell is! ValueCell<V>) {
    throw StateError(
      'CellScope.valueOf<$V>($id): registered cell is '
      '${cell.runtimeType}, which is not a ValueCell<$V>. '
      'Use CellScope.of for non-ValueCell sources.',
    );
  }
  return cell;
}