2 thoughts on “Analyzer: convert StatelessWidget to StatefulWidget

  1. 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
          )
        );
      }
    }

Comments are closed.