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

前端 未结 14 1898
悲&欢浪女
悲&欢浪女 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:43

    A StatelessWidget will never rebuild by itself (but can from external events). A StatefulWidget can. That is the golden rule.

    BUT any kind of widget can be repainted any times.

    Stateless only means that all of its properties are immutable and that the only way to change them is to create a new instance of that widget. It doesn't e.g. lock the widget tree.

    But you shouldn't care about what's the type of your children. It doesn't have any impact on you.

提交回复
热议问题