title: Flutter field must not be final in Stateful widget
body: <p>Flutter is complaining about the <code>_isSelected</code> because it is not <code>final</code>. The problem is that is <code>must not</code> be final because it is changed on a <code>buttonPressed</code>...</p>
  <pre><code>class SelectionButton extends StatefulWidget {
    final String title;
    final Function(String) onSelectionButtonTap;
    bool isSelected;
  
    SelectionButton({
      required this.title,
      required this.onSelectionButtonTap,
      required this.isSelected,
    });
    @override
    _SelectionButtonState createState() =&gt; _SelectionButtonState();
  }
  
  class _SelectionButtonState extends State&lt;SelectionButton&gt; {
    @override
    Widget build(BuildContext context) {
      return Expanded(
        child: GestureDetector(
          onTap: () {
            setState(() {
              widget.onSelectionButtonTap(widget.title);
              widget.isSelected = !widget.isSelected;
            });
          },
          child: Container(
            decoration: BoxDecoration(
              color: widget.isSelected ? AppColors.primary : AppColors.white,
              borderRadius: BorderRadius.circular(
                scaleWidth(10),
              ),
            ),
            child: Center(
              child: Text(
                widget.title,
                textAlign: TextAlign.center,
                style: widget.isSelected
                    ? AppTextStyles.h5White
                    : AppTextStyles.h5Light,
              ),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>This is the warning that Flutter is giving me:</p>
  <blockquote>
  <p>This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: SelectionButton.isSelected</p>
  </blockquote>
  <p>As you can see I am changing <code>widget.isSelected</code>. I am quite new to flutter and don't know why Flutter is complaining here. Everything is working as expected but I guess it is not <em>best practice</em>? How can I fix this issue? What am I missing here?</p>