What are Stateful and Stateless widgets?

avatar
46    1 year ago

What are Stateful and Stateless widgets?

Answers { 1 }
avatar
1 year ago

TL;DR: A widget that allows you to refresh the screen is a Stateful widget. A widget that does not is Stateless.

In more detail, a dynamic widget with content that can change should be a Stateful widget. A Stateless widget can only change content when the parameters are changed and hence needs to be done above the point of its location in the widget hierarchy. A screen or widget containing static content should be a stateless widget but to change the content, needs to be stateful.