728x90
반응형
State 패턴
1. State 클래스를 생성한다
class TodoListState{}
2.ChangeNotifier를 만들고, state 값을 초기화한다.
ex) class TodoList with ChageNotifier {
TodoListState state = TodoListState(todos:[]);
}
3. state를 바꾸고, listener들에게 변화를 알린다.
state = state.copyWith(...);
notifyListners();
728x90
반응형
'Flutter(dart)' 카테고리의 다른 글
| Could not find a file named "pubspec.yaml" (0) | 2022.11.09 |
|---|---|
| 플러터 build 터미널 명령어 (0) | 2022.11.07 |
| ChangeNotifierProvider (0) | 2022.11.06 |
| Container와 Child의 관계 도식화 (margin, padding) (0) | 2022.11.06 |
| Please enable Developer Mode in your system settings (0) | 2022.11.02 |