Not sure if this is the right component to file this, but it would be nice to have an automated refactor mechanism to convert an existing StatelessWidget and split it into a StatefulWidget and a State with one click.
I think there should be an anaylzer plugin for Flutter like https://github.com/dart-lang/angular_analyzer_plugin
@devoncarew @scheglov
class KeyRow extends StatelessWidget {
const KeyRow(this.keys);
final List<Widget> keys;
@override
Widget build(BuildContext context) {
return new Expanded(
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: keys
)
);
}
}
Is converted into:
class KeyRow extends StatefulWidget {
const KeyRow(this.keys);
final List<Widget> keys;
@override
KeyRowState createState() {
return new KeyRowState();
}
}
class KeyRowState extends State<KeyRow> {
@override
Widget build(BuildContext context) {
return new Expanded(
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: widget.keys
)
);
}
}
Most helpful comment
Is converted into: