I am looking a way to detect if OS dark mode is active, using Flutter. I just want my app to follow the OS dark mode setting. I've googling it and most of the topics are about "setting & switching" dark mode, not about detect the OS' dark mode.
You can use platformBrightness
to detect current mode of OS
bool isDarkMode() {
final darkMode = WidgetsBinding.instance.platformDispatcher.platformBrightness;
if (darkMode == Brightness.dark) {
return true;
} else {
return false;
}
}