I am developing an application in Flutter (with a webview) and when dark mode is activated on the device, the webview changes the colors of the web (text and background) to make it dark , creating a horrible result. I have tried to set the entire app in light mode (themeMode: ThemeMode.light) but it doesn’t work. i also set colour is white in my website its looks normal in Chrome. Do you know how it could be solved? Thank you?
Asked
Active
Viewed 399 times
0
-
Have you tried restarting the application after doing the changes? – Ashok Jun 13 '21 at 19:30
-
Ashok i do this many time but not work – Alok Dubey Jun 13 '21 at 19:36
-
have u found an answer for this? – John Joe Jun 24 '21 at 05:03
-
No John Still panding – Alok Dubey Jun 24 '21 at 05:51
1 Answers
0
Add the below dependency to your gradle
build:
implementation 'androidx.webkit:webkit:1.3.0'
And add the below code snippet to your webview initialization
:
if(WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
WebSettingsCompat.setForceDark(myWebView.getSettings(), WebSettingsCompat.FORCE_DARK_ON);
}

Ashok
- 3,190
- 15
- 31
-
-
-
Thank you Ashok for your efforts can you please clear this where I can use this snippet in my code. I try to use but not understand how I can use snippet. – Alok Dubey Jun 14 '21 at 05:30