LogoSignals.dart
Copy Markdown
rodydavis/signals.dart 999999

Watch

A deprecated widget for watching signal changes in the widget tree.

A deprecated widget for watching signal changes in the widget tree.

DEPRECATED: Use SignalBuilder instead for superior, self-contained reactivity and consistent API design.

Migration to SignalBuilder#

// Deprecated legacy pattern:
Watch((context) => Text('$counter'))

// Modern, streamlined pattern:
SignalBuilder(builder: (context) => Text('${counter.value}'))

Constructors#

View Constructors
Watch(this.builder, {super.key, this.debugLabel, this.dependencies = const []})

Minimal builder for signal changes that rerender a widget tree.

final counter = signal(0);
...
Watch((context) => Text('$counter'))
Watch.builder({super.key, required this.builder, this.debugLabel, this.dependencies = const []})

Drop in replacement for the Flutter builder widget.

final counter = signal(0);
...
- Builder(
+ Watch.builder(
  builder: (context) {
    return Text('$counter');
  }
)

Properties#

View Properties
T Function(BuildContext context) builder

The widget to rebuild when any signals change

String? debugLabel

Optional debug label to use for devtools

List<core.ReadonlySignal> dependencies

List of optional dependencies to watch

Methods#

View Methods
Widget build(BuildContext context)