watch method
Watches a beacon and triggers a widget rebuild when its value changes.
Note: must be called within a widget's build method.
Usage:
final counter = Beacon.writable(0);
class Counter extends StatelessWidget {
const Counter({super.key});
@override
Widget build(BuildContext context) {
final count = counter.watch(context);
return Text(count.toString());
}
}
Implementation
T watch(BuildContext context) {
final key = identityHashCode(context);
return _watchOrObserve(
key,
context,
);
}