What is the relation between stateful and stateless widgets in Flutter?

Posted by Jessica Taylor | Updated on

What is the relation between stateful and stateless widgets in Flutter?

Stateless : Widget state creates ONLY ONCE, then it can update values but not state explicitly. This is clear from there structure as well. That’s why it has only one class which extends with StatelessWidget. So if I say, they can never re-run build() method again.

Stateful : Widgets can update their STATE (locally) & values multiple times upon event triggered. That’s the reason, the implementation is also different. In this, we have 2 classes, one is StatefulWidget & the other is it’s State implementation handler i.e. State. So if I say, they can re-run build() method again & again based on events triggered.

Below diagram will help.

stateful and stateless widgets in Flutter


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers