title: Flutter - Can't change child state from parent widget
body: <p><strong>Problem</strong>: <br/></p>
  
  <p>I have a parent widget <code>SnippetTestEditor</code> and a stateful child widget <code>NoteTab</code>. If a button in the parent widget is pressed, the child widget should get updated. <br/></p>
  
  <p>Both classes have a bool <code>_editMode</code>. I pass the bool from the parent widget to the child widget via the constructor. From my understandig, I need to call <code>setState()</code> in the parent widget and change the bool within <code>setState()</code>. This change should automatically be reflected in the child widget. But it's not....<br/></p>
  
  <p>So how can I get the child widget to change? <br/></p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>class _SnippetTestEditorState extends State&lt;SnippetTestEditor&gt; with SingleTickerProviderStateMixin {
  
    bool _editMode = true;
    ...
  
    @override
    void initState() {
      super.initState();
  
      _tabs = List();
      _tabNames = List();
  
      List&lt;CodeSnippet&gt; codeSnippets = this.widget._note.codeSnippets;
      for(CodeSnippet snippet in codeSnippets){
        _tabs.add(CodeTab(_editMode);
  
      ...
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
      ...
      body: TabBarView(
            controller: _tabController,
            children: _tabs
      ),
      ...
      actions: &lt;Widget&gt;[ 
         IconButton(
            icon: Icon(Icons.check),
            onPressed: (){
              setState(() {
                _editMode = false;
              });
            },
          )
      ...
  </code></pre>
  
  <p></p>
  
  <pre><code>class CodeTab extends StatefulWidget{
  
    bool _editMode;
  
    CodeTab(this._editMode);
  
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; CodeTabState();
  
  }
  
  class CodeTabState extends State&lt;CodeTab&gt; {
  
  
    @override
    Widget build(BuildContext context) {
  
    return this.widget._editMode ? ...
  </code></pre>