728x90 반응형 Flutter(dart)26 Could not find a file named "pubspec.yaml" 해당 프로젝트 터미널 창에서 flutter pub cache clean 2022. 11. 9. 플러터 build 터미널 명령어 flutter pub run build_runner build 2022. 11. 7. State 패턴 State 패턴 1. State 클래스를 생성한다 class TodoListState{} 2.ChangeNotifier를 만들고, state 값을 초기화한다. ex) class TodoList with ChageNotifier { TodoListState state = TodoListState(todos:[]); } 3. state를 바꾸고, listener들에게 변화를 알린다. state = state.copyWith(...); notifyListners(); 2022. 11. 6. ChangeNotifierProvider ChangeNotifierProvider = ChangeNotifier + Provider ChangeNotifierProvider는 기능 1. ChangeNotifier의 인스턴스를 만든다. 기능 2. ChangeNotifier를 필요로 하는 위젯에 쉽게 접근할 수 있는 수단을 제공하고, 필요하면 UI를 rebuild한다. Provider.of를 통해서 접근할 때, 2가지 방법이 있다. 첫번째 Provider.of(context) 를 통해서는 changenotifier의 인스턴스의 변화가 있으면 UI를 리빌드 할수있다. (데이터와 UI의 동기화) 두번째 Provider.of(context, listen:false) 를 통해서는 changenotifier의 인스턴스를 액세스만 하고, 변화는 액세스하지 않.. 2022. 11. 6. 이전 1 2 3 4 5 6 7 다음 728x90 반응형