Flutter’s (Stateful) Widget Lifecycle

flutter

Every Flutter Widget has a built-in lifecycle: A collection of methods that are automatically executed by Flutter (at certain points of time).

There are three extremely important (stateful) widget lifecycle methods you should be aware of:

  • initState(): Executed by Flutter when the StatefulWidget’s State object is initialized
  • build(): Executed by Flutter when the Widget is built for the first time AND after setState() was called
  • dispose(): Executed by Flutter right before the Widget will be deleted (e.g. because it was displayed conditionally)

Leave a Reply

Your email address will not be published. Required fields are marked *