valueOf<V> static method
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
ValueCellwhose value type does not satisfyV, or when the registration is not aValueCellat all.
See Also:
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;
}