SignalAnimatedBuilder class

A reactive builder widget designed for performance optimizations using child caching.

SignalAnimatedBuilder is the modern, drop-in replacement for Flutter's native AnimatedBuilder or the deprecated WatchBuilder.

When you have a complex or computationally heavy widget subtree that does not depend on any signal values, you should pass it as the child parameter. This subtree is cached and is never rebuilt when the signals mutate, delivering a massive rendering boost.

Performance Optimization Example

final count = signal(0);

class OptimizedCounter extends StatelessWidget {
  const OptimizedCounter({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SignalAnimatedBuilder(
        // 1. Define the heavy subtree once. It will be cached:
        child: const HeavyComplexSubtreeWidget(),

        // 2. The builder receives the cached child:
        builder: (context, cachedChild) {
          return Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Dynamic Count: ${count.value}'),
              const SizedBox(height: 20),
              // 3. Render the cached child directly:
              cachedChild!,
            ],
          );
        },
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => count.value++,
        child: const Icon(Icons.add),
      ),
    );
  }
}

Tip

Always use SignalAnimatedBuilder when rendering dynamic signal values alongside static, heavy subtrees. This minimizes CPU cycles and avoids rebuilding static layouts on frame updates.

Inheritance
Available extensions

Constructors

SignalAnimatedBuilder({Key? key, required Widget builder(BuildContext context, Widget? child), Widget? child, String? debugLabel, List<ReadonlySignal> dependencies = const []})
Creates a SignalAnimatedBuilder widget.
const

Properties

builder Widget Function(BuildContext context, Widget? child)
The widget to rebuild when any signals change.
final
child Widget?
Optional pre-built child subtree that does not rebuild.
final
debugLabel String?
Optional debug label to use for devtools.
final
dependencies List<ReadonlySignal>
List of optional dependencies to watch.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toSignalWidget() SignalWidget

Available on StatelessWidget, provided by the StatelessWidgetConvertWidgetExtension extension

Converts this StatelessWidget to a SignalWidget.
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited