getx icon indicating copy to clipboard operation
getx copied to clipboard

GetX Get.changeTheme not update

Open mdtuyen opened this issue 5 months ago • 2 comments

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;
                },
              ),

mdtuyen avatar Aug 29 '24 09:08 mdtuyen