Hello everyone 🤩, the third part of our flutter roadmap topics. Stateful Widget 🎉, let’s learn together…
When writing a flutter app, we often deal with states. This article will teach you how to build and manage a Stateful Widget
State is one of the most common words used in software engineering. Flutter definition of the state is pretty straightforward, so let’s stick with that. A WİDGET THAT HAS MUATEBLE STATE 🤓. A stateful widget is dynamic: for example, it can change its appearance in response to events triggered by user interactions or when it receives data checkbox, radio, form, textfield are examples of stateful widgets. Stateful widgets subclass stateful.
A widget’s state is stored in a state object, separating the widget’s state from its appearance. The state consists of values that can change, like a slider’s current value or whether a checkbox is checked. When the widget’s state changes, the state object calls setState() , telling the framework to redraw the widget.
🥳 STATEFUL WİDGET LIFECYCLE 🥳
The concept of state is defined by two things:
1- The data used by the widget might change.
2- The data can’t be read synchronously when the widget is built.
The lifecycle has the following simplified steps;
⚫️ createState()
⚫️ mounted == true
⚫️ initState()
⚫️ didChangeDependencies()
⚫️ build()
⚫️ didUpdateWidget()
⚫️ setState()
⚫️ deactivate()
⚫️ dispose()
⚫️ mounted == false