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.
'플러터(Flutter) > 플러터 일반(Flutter General)' 카테고리의 다른 글
Flutter macOS Setup (0) | 2020.03.18 |
---|---|
Random number generator (0) | 2020.03.18 |
Custom Fonts in Your Flutter App (0) | 2020.03.18 |
Hot Reload and Hot Restart - Flutter (0) | 2020.03.18 |
플러터 프로젝트 생성(Create flutter project), Scaffold, Assets & pubspec.yaml, App icon (0) | 2020.01.09 |