window.matchMedia('(prefers-color-scheme: dark)').matches returns false in Android

Viewed 425

I am working on a Cordova Application. I want to detect if the device has dark mode or light mode enabled. I used this code to do so window.matchMedia('(prefers-color-scheme: dark)').matches. it works fine for iOS but for Android it always returns false.

int darkModeEnabled = window.matchMedia('(prefers-color-scheme: dark)').matches
alert('Dark Mode enabled: '+ darkModeEnabled);

I turned on Dark Mode in Android Settings. But it always returns false.

1 Answers
Related