티스토리 뷰
Flutter
[Flutter][GetX] Conditions must have a static type of 'bool'.Try changing the condition.
_dodo 2022. 8. 7. 17:01[문제코드]
class ThemeViewModel extends GetxController{
RxBool isLightTheme = false.obs;
void changeTheme() {
if (isLightTheme) {
Get.changeThemeMode(ThemeMode.dark);
isLightTheme = false; // 문제 발생
} else {
Get.changeThemeMode(ThemeMode.light);
isLightTheme = true; // 문제 발생
}
}
}
[해결]
class ThemeViewModel extends GetxController{
RxBool isLightTheme = false.obs;
void changeTheme() {
if (isLightTheme.isTrue) {
Get.changeThemeMode(ThemeMode.dark);
isLightTheme(false); // 해결
} else {
Get.changeThemeMode(ThemeMode.light);
isLightTheme(false); // 해결
}
}
}
RxBool 타입은 일반적인 Bool이 아니라 발생하는 문제였습니다.
Rx타입의 메소드를 이용해주면 됩니다.
'Flutter' 카테고리의 다른 글
| [Flutter] BottomNavigationBar 커스텀하기 (0) | 2022.08.16 |
|---|---|
| [Flutter] 하단탭바, BottomNavigationBar 만들기 (0) | 2022.08.10 |
| [Flutter] 전체 폰트 변경하기 (0) | 2022.08.03 |
| [Flutter][GetX] GetX로 다크모드 만들기 (2) - 커스텀 색상 적용하기 (0) | 2022.07.29 |
| [Flutter][GetX] GetX로 다크모드 만들기 (1) (0) | 2022.07.28 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- MVVM
- Swift Concurrency
- GetX
- Architecture Pattern
- Bloking/Non-bloking
- MVC
- programmers
- TestCode
- 아키텍쳐 패턴
- SwiftUI
- DocC
- 노션
- 프로그래머스
- Flutter
- notion
- RX
- swift
- MVI
- 리액티브 프로그래밍
- coordinator pattern
- healthkit
- combine
- design pattern
- reactive programming
- Flux
- 코디네이터 패턴
- ios
- SWM
- 비동기/동기
- 소프트웨어마에스트로
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
글 보관함
