Stateful/stateless widgets
In Chapter 1, An Introduction to Flutter, we learned that widgets play an important role in Flutter application development. They are the pieces that form the UI; they are the code representation of what is visible to the user.
UIs are almost never static; they change frequently, as you will have experienced when you have used a web page or an application. Although immutable by definition, widgets are not meant to be final – after all, we are dealing with a UI, and a UI will certainly change during the life cycle of any application. That's why Flutter provides two types of widgets: stateless and stateful.
Immutability
Most programming languages refer to the term "immutable." An immutable object is an object that never changes. That is, it cannot change itself, and it cannot be changed externally. Instead, if a change is needed, then the object is simply replaced. A stateless widget is immutable because it cannot change its properties...