The state of an app can very simply be defined as anything that exists in the memory of the app while the app is running. This includes all the widgets that maintain the UI of the app including the buttons, text fonts, icons, animations, etc. So now as we know what are these states let’s dive directly into our main topic i.e what are these stateful and stateless widgets and how do they differ from one another.
Stateful Widget
Stateful Widgets are widgets whose state can be changed after they’ve been built. These states are changeable, meaning they can change several times throughout their lives. This basically means that an app’s state can change several times depending on various variables, inputs, and data. It’s employed when the user interface can alter on the fly. CheckBox, RadioButton, Form, and TextField are some examples.Immutable classes derive from “Stateful Widget.” However, the State is mutable, and it changes over time when the user interacts with it.
Stateless Widget
Stateless widgets are those whose state cannot be changed once they have been created. Once developed, these widgets are immutable, which means that any changes to the variables, icons, buttons, or data retrieval will not affect the app’s state. Stateless widgets include Icon, IconButton, and Text. Stateless widgets subclass StatelessWidget.
Official document : https://docs.flutter.dev/ui/interactivity#creating-stateful-widget
We would like to suggest to take a look this Youtube video also which is useful one when we study.