title: flutter - update TextField/TextEditingController via state (provider/consumer)
body: <p>i have a TextField on a "page".  i have a TextEditingController hooked to it.  I can successfully set the value of the TextField via something easy like:</p>
  
  <pre><code>usernameController.text = '1234';
  </code></pre>
  
  <p>however, i need to be able to change this field from a child page.  the use case is a login form where the user logs out from inside the app.  when i return to the login page, i want the username/password to be wiped out/deleted.  right now, the values are still there (showing whatever is currently in usernameController.text)</p>
  
  <p>overall, i'm managing state via Provider.  i can set and retrieve/display state in other places in my app with no problem.  the issue becomes that the controller is setup via dart code in initState().  it is not part of a widget that gets rebuilt.  </p>
  
  <p>i can setup the TextField widget within a consumer.  the builder gets called when state is updated in the child page (confirmed with the debug print statement) but the widget itself does not reflect the new value of the state (it still has the old username and it is not blanked out).</p>
  
  <pre><code>                            Consumer&lt;myAppState&gt;(
                            builder: (context, appState, child) {
                              print("in builder for consumer: ");
                              print(appState.username);
                              return Container(
                                  width: 200,
                                  child: TextField(
                                    controller: usernameController,
                                    onChanged: (value) =&gt; _saveUsername(value),
                                    decoration: InputDecoration(
                                      hintText: 'Username',
                                      prefixIcon: Icon(Icons.account_circle),
                                    ),
                                  ));
                            }),
  </code></pre>
  
  <p>I've tried replacing</p>
  
  <pre><code>usernameController.text = '1234';
  </code></pre>
  
  <p>with: </p>
  
  <pre><code>usernameController.text = Provider.of&lt;myAppState&gt;(context, listen: true).username;
  </code></pre>
  
  <p>but that does not seem to work.</p>
  
  <p>it seems this "non-pure" widget (because of the controller being handled programatically) doesn't sit pretty within the Consumer model which wants to redraw widgets.  </p>
  
  <p>anyone have any thoughts?</p>
  
  <p>thanks!</p>