title: Flutter switch widget not updating
body: <p>I have created a stateless widget that has a Flutter switch widget I implement this widget in the parent and pass in the required parameters but it won't change value when I press the switch.</p>
  
  <p>I thought it might have been due to the fact that the child widget wasn't stateful but that made no difference.</p>
  
  <p>Here is a brief example of code from my two widget files</p>
  
  <pre><code>class SettingsButton extends StatelessWidget {
   final String text;
   final bool initalValue;
   final void Function(bool) onOffCallback;
  
   SettingsButton({
      this.text,
      this.initalValue = false,
      this.onOffCallback,
    });
  
  @override
    Widget build(BuildContext context) {
      return Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: &lt;Widget&gt;[
        Container(
          width: MediaQuery.of(context).size.width,
          child: SubHeading(text),
        ),
        Switch(
          onChanged: isOnOff ? onOffCallback : null,
          activeColor: Theme.of(context).accentColor,
          value: initalValue,
        )
      ]);
  </code></pre>
  
  <pre><code>class _SettingsState extends State&lt;Settings&gt; {
    bool test = true;
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        backgroundColor: Theme.of(context).backgroundColor,
        body: ListView(
          children: [
            Column(
              children: [
                SettingsButton(
                  text: "Test",
                  onOffCallback: (test) =&gt; setState(() {
                    print("Called");
                    test = !test;
                  }),
                  initalValue: test,
                ),
              ],
            )
          ],
        ),
      );
    }
  </code></pre>