context_watch_signals 3.0.3 copy "context_watch_signals: ^3.0.3" to clipboard
context_watch_signals: ^3.0.3 copied to clipboard

context_watch adapter for signals package

See https://pub.dev/packages/context_watch

Usage #

Remove signals_flutter from your pubspec.yaml. context_watch_signals re-exports everything from signals_flutter except the original watch() and unwatch() extensions, so that you don't have name resolution conflicts.

Add SignalContextWatcher.instance to additionalWatchers of ContextPlus.root:

ContextPlus.root(
  additionalWatchers: [
    SignalContextWatcher.instance,
  ],
  child: ...,
);

Observe Signals with Signal.watch(context) or Signal.watchOnly(context, () => ...):

final _counter = signal(0);

class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final counter = _counter.watch(context);
    final counterSquared = _counter.watchOnly(context, (counter) => counter * counter);
    return Text('Counter: $counter, Counter²: $counterSquared');
  }
}
3
likes
150
points
182
downloads

Publisher

verified publishersonerik.dev

Weekly Downloads

context_watch adapter for signals package

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

context_watch_base, flutter, signals_flutter

More

Packages that depend on context_watch_signals