Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetX Get.changeTheme not update #3195

Open
mdtuyen opened this issue Aug 29, 2024 · 2 comments
Open

GetX Get.changeTheme not update #3195

mdtuyen opened this issue Aug 29, 2024 · 2 comments
Assignees

Comments

@mdtuyen
Copy link

mdtuyen commented Aug 29, 2024

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;
                },
              ),
@jonataslaw
Copy link
Owner

jonataslaw commented Aug 29, 2024

Are you using the version 4?

@xiaopindev
Copy link

I also encountered the same problem, on the simulator is normal, on the real machine execution does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants