title: Controlling State from outside of a StatefulWidget
body: <p>I'm trying to understand the best practice for controlling a StatefulWidget's state outside of that Widgets State. </p>
  
  <p>I have the following interface defined. </p>
  
  <pre><code>abstract class StartupView {
    Stream&lt;String&gt; get onAppSelected;
  
    set showActivity(bool activity);
    set message(String message);
  }
  </code></pre>
  
  <p>I would like to create a StatefulWidget <code>StartupPage</code> that implements this interface. I expect the Widget to do the following:</p>
  
  <ol>
  <li><p>When a button is pressed it would send an event over the onAppSelected stream. A controller would listen to this even and perform some action ( db call, service request etc ).</p></li>
  <li><p>The controller can call <code>showActivity</code> or <code>set message</code> to have the view show progress with a message.</p></li>
  </ol>
  
  <p>Because a Stateful Widget does not expose it's State as a property, I don't know the best approach for accessing and modifying the State's attributes. </p>
  
  <p>The way I would expect to use this would be something like:</p>
  
  <pre><code>Widget createStartupPage() {
      var page = new StartupPage();
      page.onAppSelected.listen((app) {
        page.showActivity = true;
        //Do some work
        page.showActivity = false;
      });
    }
  </code></pre>
  
  <p>I've thought about instantiating the Widget by passing in the state I want it to return in <code>createState()</code> but that feels wrong.</p>
  
  <p>Some background on why we have this approach: We currently have a Dart web application. For view-controller separation, testability and forward thinking towards Flutter we decided that we would create an interface for every view in our application. This would allow a WebComponent or a Flutter Widget to implement this interface and leave all of the controller logic the same. </p>