nylo-core / nylo

Nylo is the fastest way to build your next Flutter mobile app. Streamline your projects with Nylo's opinionated approach to building Flutter apps. Develop your next idea ⚡️
https://nylo.dev
MIT License
586 stars 58 forks source link

Dark/Light theme switch is not working on Android when the device’s dark theme is selected from the settings #164

Closed tayfunuyar closed 3 weeks ago

tayfunuyar commented 4 weeks ago

Hi, The dark and light theme switch is not working correctly when the device is set to the default dark theme in the system settings.

  ListTile(
                  dense: true,
                  title: Text('darkMode'.tr(), style: TextStyle(fontSize: 16)),
                  leading:
                      Icon(isThemeDark() ? Icons.dark_mode : Icons.light_mode),
                  trailing: Switch(
                    value: isThemeDark(),
                    onChanged: (value) {
                      NyTheme.set(context,
                          id: value ? 'dark_theme' : 'light_theme');
                      setState(() {});
                    },
                  ),
                ),

   bool isThemeDark() {
    var isThemeDark = ThemeProvider.controllerOf(context).currentThemeId ==
        getEnv('DARK_THEME_ID');
    return isThemeDark;
  }
agordn52 commented 3 weeks ago

Hi @tayfunuyar,

I think this is related to this https://github.com/nylo-core/framework/issues/29#issuecomment-1701907118 Check out my comment there 👍