getx
getx copied to clipboard
GetX Get.changeTheme not update
I use getX in my project, when changing theme, it doesn't work. Here is my code: From dialog choose theme:
onConfirm: () {
SPUtils.to.saveTheme(theme: currentTheme);
Get.changeTheme(AppTheme.keys[currentTheme]!);
Navigator.pop(Get.overlayContext!, true);
});
From Main:
return ScreenUtilInit(
minTextAdapt: true,
splitScreenMode: true,
builder: (_, __) {
return GetMaterialApp(...)
});
Screen order: Splash > HomeScreen
Home screen has 4 BottomNavigationBarItem, when I change theme by clicking on the item in the setting screen, the setting screen does not update the new theme, the theme only updates when I click to other bottom tabs
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
body: {4: ScanScreen(), 0: NaturalWorldScreen(), 1: MyIdScreen(), 2: ReminderScreen()}[indexPage.value] ??
SettingScreen(),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.white,
items: [
BottomNavigationBarItem(
icon: IZIImage.icon(Icons.dataset, color: selectColor(indexPage.value == 0)), label: ''),
BottomNavigationBarItem(
icon: IZIImage.icon(Icons.favorite, color: selectColor(indexPage.value == 1)), label: ''),
BottomNavigationBarItem(
icon: IZIImage.icon(Icons.timer, color: selectColor(indexPage.value == 2)), label: ''),
BottomNavigationBarItem(
icon: IZIImage.icon(Icons.settings, color: selectColor(indexPage.value == 3)), label: ''),
],
showSelectedLabels: false,
showUnselectedLabels: false,
currentIndex: indexPage.value > 3 ? 0 : indexPage.value,
onTap: (index) {
selectIndex.add(indexPage);
indexPage.value = index;
},
),