switchTheme method
Implementation
Future<bool> switchTheme({BuildContext? context}) async{
//No dark theme in the configuration, so skip this
if(_theme?.darkTheme == null) return false;
final isDark = isDarkTheme();
if(isDark){
logNUI("NUITheme", "Switching from dark theme to light theme");
await _updateSelectedTheme(false);
}
else{
logNUI("NUITheme", "Switching from light theme to dark theme");
await _updateSelectedTheme(true);
}
if(context != null){
final child = NUIThemeContainer.of(context);
if(child != null) {
child.refresh();
}
final parent = NUIThemeParentContainer.of(context);
if(parent != null) {
parent.refresh();
}
}
NUIBusEvent.get(module: BROADCAST_THEME_MODULE).send(NUIBusEventData<NUIColorTheme>(data: theme, sender: MODULE, code: CODE_THEME_SWITCHED));
return true;
}