Flutter-Stateful or Stateless widgets?

Spread the love

Stateless widgets
widgets that don’t need to manage any form of internal state.

1 yWdm1QER62 z6DK9sa2Bw

"A stateless widget has no internal state to manage. Icon, IconButton, and Text are examples of stateless widgets, which subclass StatelessWidget"

Stateful widgets
Stateful widgets are dynamic.

They allow us to create widgets which can dynamically change their content over time and don’t rely on static states which are passed in during their instantiation.

1 vgx3Fi OB6M0O qSigBiQ

"A stateful widget is dynamic. The user can interact with a stateful widget (by typing into a form, or moving a slider, for example), or it changes over time (perhaps a data feed causes the UI to update). Checkbox, Radio, Slider, InkWell, Form, and TextField are examples of stateful widgets, which subclass StatefulWidget."

1 6Vjq1heqFSFEb sqocWIww
stateful vs stateless