0

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?

Alok Dubey
  • 44
  • 5

1 Answers1

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);
}

Can check the Credits here

Ashok
  • 3,190
  • 15
  • 31