LogoSignals.dart
Copy Markdown
rodydavis/signals.dart 999999

WatchBuilder

WatchBuilder.

WatchBuilder#

To watch a signal for changes in Flutter, use the WatchBuilder widget. This will only rebuild this widget method and not the entire widget tree.

final signal = signal(10);
...
@override
Widget build(BuildContext context) {
  return WatchBuilder(
    child: const Icon(Icons.add),
    builder: (context, child) => Row(children: [Text('$signal'), child!]),
  );
}

Constructors#

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

Minimal builder for signal changes that rerender a widget tree.

final counter = signal(0);
...
WatchBuilder(
  builder: (context, child) => Text('$counter')
)

Properties#

View Properties
T Function(BuildContext context, Widget? child) builder

The widget to rebuild when any signals change

String? debugLabel

Optional debug label to use for devtools

Widget? child

Cached widget to pass in

List<core.ReadonlySignal> dependencies

List of optional dependencies to watch

Methods#

View Methods
Widget build(BuildContext context)