title: Flutter correct way to provide a callback function to a stateless widget
body: <p>I have a stateless widget ( a side panel). When some button on side panel is pressed, it is supposed to call a function which is in its parent stateful widget. This function has an input type String.</p>
  <p>My call back function is:</p>
  <pre><code>    sidePanelTapped(String option){
          switch (option){
            case NEW : {
              if (kDebugMode) print('TappedOption = 1');
              setState(() =&gt; tappedOption=1);
            } break;
            case PROGRESS : {
              if (kDebugMode) print('TappedOption = 2');
              setState(() =&gt; tappedOption=2);
            } break;
  .
  .
  .
  </code></pre>
  <p>My stateless widget has this format:</p>
  <pre><code>class SidePanel extends StatelessWidget {
    final Function funct;
    final int tappedOption;
    SidePanel({required this.funct, required this.tappedOption});
  </code></pre>
  <p>Then in my build section my code is as follows:</p>
  <pre><code>.
  .
  .
  Container(
                            margin: EdgeInsets.only(bottom: 5.0),
                            child: GestureDetector(
                              onTap: ()=&gt;funct(optionEntry.key),
                              child: ListTile(
                                minVerticalPadding: 1.0,
                                tileColor: optionEntry.key == NEW
                                    ? tappedOption == 1? Colors.grey[200] 
  .
  .
  .
  </code></pre>
  <p>The problem is that my side panel is not changing state as it is suppose to. What am I doing wrong here?</p>