initState() is a method of class State and it is considered as an important lifecycle method in Flutter. initState() is called only Once and we use it for one time initializations. Example : To initialize data that depends on the specific BuildContext . To initialize data that needs to executed before build() .
Read moreWhy are StatefulWidget and state separate classes flutter?
There are multiple reasons : Widgets are immutable . Since StatefulWidget extends Widget it therefore must be immutable too. Splitting the declaration into two classes allows both StatefulWidget to be immutable and State to be mutable.
Read moreWhat is flutter build method?
The flutter build method in flutter describes the user interface represented by this widget when it is inserted in the build context provided in the widget tree and the dependency of the widget is changed .
Read moreDoes a new state object is created if the widget re build?
The State object consists of values that can change. The State object contains its associated widget’s ‘mutable state . ‘ — it stores values that can change over time. When those values have changed, more often than not, the associated StatefulWidget is re-created.
Read moreWhat’s the job of the build () method?
build method Null safety Describes the part of the user interface represented by this widget . The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change (e.g., an InheritedWidget referenced by this widget changes).
Read moreWhat is the main purpose of setState () method call?
Calling setState notifies the framework that the internal state of this object has changed in a way that might impact the user interface in this subtree, which causes the framework to schedule a build for this State object.
Read more