StatefulWidgets are separated into 2 classes because one part is entirely immutable . Widget subclass cannot store any mutable field. We are not in React where “Components” are mutable and the instance stays the same for the whole life of the component.
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 more