An IDE quick-fix refactoring tool (Dart Assist) that automatically migrates a deprecated
SignalsMixin usage on a State class to extend the reactive
SignalStatefulWidget instead.
:::important
Since SignalsMixin is deprecated in signals v7, this automated quick-fix does two things:
- Removes
SignalsMixinfrom your State class'swithclause. -
Changes the parent widget class's superclass from
StatefulWidgettoSignalStatefulWidget. This results in a cleaner, highly optimized codebase that runs with zero unnecessary overhead. :::
How to use#
- Place your cursor on the
SignalsMixinname in the State's class signature. -
Click the lightbulb icon or press your IDE's quick-fix shortcut (
Alt+EnterorCmd+.). - Select the Migrate SignalsMixin to SignalStatefulWidget assist option.
Examples#
Before:
class MyWidget extends StatefulWidget {
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> with SignalsMixin { // LINT: Deprecated SignalsMixin
@override
Widget build(BuildContext context) {
return Text('${counter.value}');
}
}
After (Apply Assist):
class MyWidget extends SignalStatefulWidget {
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
@override
Widget build(BuildContext context) {
return Text('${counter.value}'); // OK
}
}