I have an old app to update to be Dark Themed, but I have a problem of approaching this task the right way. There is no usage of ThemeData in the MaterialApp prop, just a CustomColorPalette class that is used through the entire app. My question here is, is there a way I can just handle the switch to different colors with one bool flag inside the CustomColorPalette class, where I also store that flag in the SecureStorage for future reference no matter what way I choose, or should I rework the entire app with the ThemeData method?
The color class example:
class CustomColorPalette {
///I was thinking something like this
static bool isDarkMode = false;
static Color primaryColor = isDarkMode ? CustomColorDark.primaryColor : CustomColorLight.primaryColor
static Color secondaryColor = isDarkMode ? CustomColorDark.secondaryColor : CustomColorLight.secondaryColor
…
}
class CustomColorDark {
static Color primaryColor = Colors.black
static Color secondaryColor = Colors.black
…
}
class CustomColorLight {
static Color primaryColor = Colors.white
static Color secondaryColor = Colors.white
…
}
on button switch:
Switch(
value: colorThemeValue,
onChanged: (bool value) => _bloc..add(ToggleThemeEvent(value!))
);
As you can see, Bloc is used for state management, this is just an example of how I tried of doing but the isDarkMode flag inside the CustomColorPalette class never seems to update on event, only when I refresh the entire app since I store that bool in the SecureStorage. Thanks in advance for your time and effort, much appreciated.