📜  您对 Stateful 和 Stateless 小部件的理解是什么? - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:39.199000             🧑  作者: Mango

代码示例1
A Stateful widget has state information. It is referred to as dynamic because it can change the inner data during the widget lifetime. A widget that allows us to refresh the screen is called a Stateful widget. This widget does not have a build() method. It has createState() method, which returns a class that extends the Flutters State Class. The examples of the Stateful widget are Checkbox, Radio, Slider, InkWell, Form, and TextField.

The Stateless widget does not have any state information. It remains static throughout its lifecycle. The examples of the Stateless widget are Text, Row, Column, Container, etc. If the screen or widget contains static content, it should be a Stateless widget, but if you want to change the content, it needs to be a Stateful widget.