[Flutter] What is State?

jaehee kim·2021년 9월 2일
1

Flutter

목록 보기
10/20
post-thumbnail

What is State?

state에 대해서 알아보겠습니다.

Flutter app 에서는 일반적으로 항상 데이터와 해당 데이터를 반영하는 유저 인터페이스를 관리합니다.
그래서 데이터가 변화하게 되면 이를 반영하는 유저 인터페이스 또한 변화하게 됩니다.

여기서의 데이터를 state라고 표현합니다.

state = data which affects the UI (and which might change over time)




State의 종류

state는 두 가지 종류가 있습니다.

App-wide State

이름에서 추측해볼 수 있는 것처럼 앱 전체 혹은 앱의 많은 부분에 영향을 주는 state 입니다.
(Affects entire app or siginificant parts of the app)

e.g. Authentication status of a user. 유저가 로그인 상태인지 아닌지에 따라서 앱에서 보여주는 데이터가 달라질 것이다.


Widget (Local) State

해당 위젯 자체에만 영향을 주고 다른 위젯에는 영향을 주지 않는 state 입니다.
(Affects only a widget on its own(dose not affect other widgets )

e.g. loading spinner





Reference

[Flutter & Dart - The Complete Guide [2021 Edition]]

0개의 댓글