I am learning Dart/flutter and trying to understand how Widgets system works. But I can\'t understand what difference between stateless and stateful widgets? For example I h
According to flutter.io:
Stateless widget
Stateless widgets are immutable, meaning that their properties can’t change — all values are final.
Here is doc.
Stateful widget
Stateful widgets maintain state that might change during the lifetime of the widget. Implementing a stateful widget requires at least two classes: 1) a StatefulWidget class that creates an instance of 2) a State class. The StatefulWidget class is, itself, immutable, but the State class persists over the lifetime of the widget.
As a example if you want to change text in text widget when a button press, you have to use StatefulWidget and it will let you to change the state of a variable.
But in StatelessWidget you cannot do that because it doesn't keep state.
Read more from doc.
This tutorial will help anyone who trying to understand these two.