setState 원리 (setState Principle)

 

[Ko]

 - flutter는 Stateful widget과 Stateless widget을 가지며, Stateful widget만이 상태를 가질 수 있다. 상태 정보를 새로 반영하기 위해서는 setState가 실행되면서 build method가 재 실행되어서 화면이 rebuild 되어야 함.

 - setState 원리 : setState 안에 정의된 함수에 의해 값이 변경되는 변수 A, setState 실행되면 해당 build method 내에서 A 사용되는 모든 곳을 dirty 표시함 —> setState 의해 build method 재실행 되면 dirty mark 곳만을 찾아서 UI 업데이트 .

 

[En]
 - The flutter has a stateful widget and a stateless widget, and only the stateful widget can have a state. In order to reflect the new state information, the set method is executed and the build method is re-executed and the screen must be rebuilt.
 - setState Principle: Variable A whose value is changed by the function defined in setState, when setState is executed, marks everywhere where A is used within the corresponding build method —> Marks dirty when the build method is re-executed by setState Updates the UI by finding only the places where it was found.

+ Recent posts