title: Why are stateful widgets defined as two classes in flutter?
body: <p>I'm new to flutter/dart, so while I try to make an app I also try to understand why things are a certain way. In the flutter docs there is example code of a stateful widget as shown:</p>
  
  <pre><code>class YellowBird extends StatefulWidget {
    const YellowBird({ Key key }) : super(key: key);
  
    @override
    _YellowBirdState createState() =&gt; new _YellowBirdState();
  }
  
  class _YellowBirdState extends State&lt;YellowBird&gt; {
    @override
    Widget build(BuildContext context) {
      return new Container(color: const Color(0xFFFFE306));
    }
  }
  </code></pre>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>Why are they defined with two classes as opposed to one? I'm guessing the State class can be used somewhere else so it was better to be split up.</p></li>
  <li><p>From what I understand the <code>createState()</code> function returns an object of type <code>State</code>, so having <code>_YellowBirdState extends State</code> makes sense, but why is <code>YellowBird</code> passed into the generic class of <code>State</code>? My guess it has something to do with <code>Yellowbird</code> extending the <code>StatefulWidget</code> class but not quite sure. </p></li>
  </ol>