An IDE quick-fix refactoring tool (Dart Assist) that automatically converts a standard
StatefulWidget to extend the reactive SignalStatefulWidget
instead.
By extending
SignalStatefulWidget instead of StatefulWidget, your widget state automatically
registers fine-grained dependency tracking for any signals referenced within its build method. It
will rebuild automatically when their values change, removing the need for manual listener
lifecycle management or setState calls.
How to use#
-
Place your cursor on the widget class declaration (e.g.,
class MyWidget extends StatefulWidget). -
Click the lightbulb icon or press your IDE's quick-fix shortcut (
Alt+EnterorCmd+.). - Select the Convert to SignalStatefulWidget assist option.
Examples#
Before:
class CounterWidget extends StatefulWidget {
const CounterWidget({super.key});
@override
State<CounterWidget> createState() => _CounterWidgetState();
}
After (Apply Assist):
class CounterWidget extends SignalStatefulWidget {
const CounterWidget({super.key});
@override
State<CounterWidget> createState() => _CounterWidgetState();
}