cell<V> method
Returns the cell registered at id, narrowed to ValueCell<V> when
the registration is a ValueCell.
Parameters:
id: The Registration Key. TheSymbolused 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
idis not registered. - StateError when the registration is a
ValueCellwhose value type does not satisfyV.
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;
}