An IDE quick-fix refactoring tool (Dart Assist) that automatically wraps any instantiated widget expression inside a SignalBuilder component.
Wrapping a widget inside
SignalBuilder(builder: (context) => ...) optimizes rebuilding
performance by confining redraws strictly to the smallest possible sub-tree whenever
reactive signals read inside the builder change.
How to use#
- Place your cursor on any widget constructor call (e.g.,
Text('...')). -
Click the lightbulb icon or press your IDE's quick-fix shortcut (
Alt+EnterorCmd+.). - Select the Wrap with SignalBuilder assist option.
Examples#
Before (Cursor on Text constructor):
Widget build(BuildContext context) {
return Text('Counter: ${counter.value}');
}
After (Apply Assist):
Widget build(BuildContext context) {
return SignalBuilder(builder: (context) => Text('Counter: ${counter.value}'));
}