useCellValue<V> function

V? useCellValue<V>(
  1. ValueCell<V> cell
)

A convenience wrapper for "rebuild on every value change".

useCellValue is useCell with select: (v) => v — the full-value shortcut. It is the hooks layer's Plain Value Reader, the HookWidget equivalent of CellBuilder.

Why it is used

Most HookWidgets that read a cell want the whole value, not a projected slice. Rather than forcing the caller to pass select: (v) => v and infer S from the cell's V, this helper shortens the call site and infers the type directly.

When not to use it

Use only when every change matters. If the widget only reads one field of a larger object — the common case once a Cell<User> grows beyond name — reach for useCell with an explicit selector. Rebuilding the widget on every unrelated field change is the exact cost CellSelector's slice reduction exists to avoid.

How it works

It delegates to useCell<V, V?> with select: (v) => v. The selection is typed V? (matching CellNotifier's value type) and rebuilds on every distinct value.

Technical Details

  • Return type is V?: the same nullable-value contract as CellBuilder.builder — a not-yet-emitted cell returns null.
  • Delegates to useCell: no separate implementation; the equality and recompute semantics of useCell apply unchanged. Default equals is ==.

Example

class CounterView extends HookWidget {
  final ValueCell<int> counter;
  const CounterView({required this.counter, super.key});

  @override
  Widget build(BuildContext context) {
    final value = useCellValue(counter);
    return Text('${value ?? 0}');
  }
}

Parameters:

  • cell: The Source Cell. A ValueCell whose full value is read.

Returns:

The current value V?, re-rendered on every change.

See Also:

Implementation

V? useCellValue<V>(ValueCell<V> cell) =>
    useCell<V, V?>(cell: cell, select: (v) => v);