[Flutter] StatelessWidget vs StatufulWidget

쏘리초이·2021년 3월 15일
0
post-thumbnail

Stateful Widget vs Stateless Widget

Stateful Widget : 해당 클래스 안에 상태변화가 있는 위젯 (참고)

A widget that has mutable state.
State is information that (1) can be read synchronously when the widget is built and (2) might change during the lifetime of the widget. It is the responsibility of the widget implementer to ensure that the State is promptly notified when such state changes, using State.setState.

A stateful widget is a widget that describes part of the user interface by building a constellation of other widgets that describe the user interface more concretely. The building process continues recursively until the description of the user interface is fully concrete (e.g., consists entirely of RenderObjectWidgets, which describe concrete RenderObjects).

Stateful widgets are useful when the part of the user interface you are describing can change dynamically, e.g. due to having an internal clock-driven state, or depending on some system state. For compositions that depend only on the configuration information in the object itself and the BuildContext in which the widget is inflated, consider using StatelessWidget.

Stateful Widget은
1) widget이 빌드될 때 동기적으로 읽을 수 있고,
2) 생명주기 동안 변경될 수 있는 정보이다. 따라서 UI가 동적으로 변경도리 수 있는 경우에 유용하다.

Stateless Widget : 해당 클래스 안에 상태변화가 없는 위젯(참고)

A widget that does not require mutable state.

A stateless widget is a widget that describes part of the user interface by building a constellation of other widgets that describe the user interface more concretely. The building process continues recursively until the description of the user interface is fully concrete (e.g., consists entirely of RenderObjectWidgets, which describe concrete RenderObjects).

Stateless Widget은
변경 가능한 상태가 필요하지 않은 위젯.

profile
Hello Universe!

0개의 댓글