title: Stateful widget in Scaffold's body
body: <p>I don't understand why in flutter is not possible to have a structure like this:</p>
  
  <pre><code>//...
  Scaffold(
    //...
    body: myPage(dataList[index])
  )
  //...
  </code></pre>
  
  <p>Where myPage is a class that extends statefulWidget and returns a ListView. It requires a data parameter that is stored in an array. I want to change the body of my scaffold when I change the index for example with a navigation drawer.</p>
  
  <p>I noticed that:</p>
  
  <ul>
  <li>if myPage extends statelessWidget all works fine,</li>
  <li>if I have different pages classes that extends statefulWidget all works fine,</li>
  <li>but if I have myPage that requires a data to change the content nothing happend, it doesn't change, it stays on the first page</li>
  </ul>
  
  <p>And Yes, I used the setState method to refresh the layout whenever I change the index.</p>
  
  <p>Is this a bug or I missed something? If it is not a bug, what could I do as workaround? Thanks in advance</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I post the code of another page that is simpler with nothing strange where there is anyway this problem (I know in this page I could use a statelessWidget but it should work anyway):</p>
  
  <pre><code>class FirstFragment extends StatefulWidget {
    String data;
    FirstFragment(this.data);
  
    @override
    _FirstFragment createState() =&gt; new _FirstFragment(data);
  
  }
  
  class _FirstFragment extends State&lt;FirstFragment&gt;{
    String data;
    _FirstFragment(this.data);
  
    @override
    Widget build(BuildContext context) {
      // TODO: implement build
      return new Center(
        child: new Text(data),
      );
    }
  }
  </code></pre>