Watch constructor

Watch(
  1. WatchStateCallback watch, {
  2. dynamic key,
})

Register watch to be called whenever the values of the cells referenced within it change.

The function watch is called, with the created Watch object passed to it as an argument, whenever the values of the cells referenced within it change. watch is called once before the constructor returns to determine the initial cells referenced within it.

This allows the stop and afterInit methods to be called from within watch.

If key is not null and a CellWatcher identified by key has already been created, and has not been stopped, this CellWatcher object references the same watch function.

Implementation

Watch(WatchStateCallback watch, {super.key}) {
  init(() => watch(this));
}