title: Flutter: how to create a non-final property for a StatefulWidget?
body: <p>Say I want to create a button that every time that it's clicked it changes color.
  Its starting color is required in the constructor.</p>
  
  <p>The following code works fine, but  when I hover on top of TestButton I get this message: "This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: TestButton.color".</p>
  
  <p>If it should be final but I need it to change, what's the solution?
  Why does it have be final if it works anyways? </p>
  
  <pre><code>class TestButton extends StatefulWidget {
    TestButton({this.color});
    Color color;
    @override
    _TestButtonState createState() =&gt; _TestButtonState();
  }
  
  class _TestButtonState extends State&lt;TestButton&gt; {
    @override
    Widget build(BuildContext context) {
      return RaisedButton(
        onPressed: () {
          setState(() {
            widget.color = widget.color == Colors.red ? Colors.blue : Colors.red;
          });
        },
        child: Icon(
          Icons.add,
          size: 80,
        ),
        color: widget.color,
      );
    }
  }
  </code></pre>