Skip to main content

createState method

_MyAppState createState ()

<span class="feature">override</span>

<p>Creates the mutable state for this widget at a given location in the tree.</p> <p>Subclasses should override this method to return a newly created instance of their associated <a href="https:api.flutter.dev/flutter/widgets/State-class.html">State</a> subclass:</p> <pre class="language-dart"><code class="language-dart">@override State<SomeWidget> createState() => _SomeWidgetState(); </code></pre> <p>The framework can call this method multiple times over the lifetime of a <code>StatefulWidget</code>. For example, if the widget is inserted into the tree in multiple locations, the framework will create a separate <a href="https:api.flutter.dev/flutter/widgets/State-class.html">State</a> object for each location. Similarly, if the widget is removed from the tree and later inserted into the tree again, the framework will call <a href="../../main/MyApp/createState.md">createState</a> again to create a fresh <a href="https:api.flutter.dev/flutter/widgets/State-class.html">State</a> object, simplifying the lifecycle of <a href="https:api.flutter.dev/flutter/widgets/State-class.html">State</a> objects.</p>

Implementation

@override
_MyAppState createState() =\> _MyAppState();