What is the relation between stateful and stateless widgets in Flutter?

前端 未结 14 1890
悲&欢浪女
悲&欢浪女 2020-12-02 07:06

A stateful widget is defined as any widget which changes its state within its lifetime. But it is a very common practice for a StatelessWidget to have a S

14条回答
  •  清歌不尽
    2020-12-02 07:37

    What are Stateful and Stateless widgets?

    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.

    I found this relative content on an interesting medium story. You're welcome!

提交回复
热议问题