Widget Lifecycle

Learn about the various stages in a lifecycle that a Flutter widget goes through.

In the case of stateless widgets, the UI is built once. But the stateful widget maintains data as well as the state inside it and builds itself multiple times. So it goes through its own lifecycle, which we are going to learn about in this lesson.

The createState() method

The createState() method must be overridden when a Dart class extends a StatefulWidget.

The initState() method

When a stateful widget is born and gets attached to the widget tree, it calls its first method, which is initState(). Here we can initialize variables, data, properties, etc. for any widget.

Get hands-on with 1400+ tech skills courses.