flutterdartdarkmode

Disable dark mode in web view


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.

Is there a way to disable dark mode in web view?

I'm using this plugin flutter_webview_plugin


Solution

  • I managed to fix it by adding this line in android/app/src/res/values/styles.xml:

    <item name="android:forceDarkAllowed">false</item>

    Here my full code

    
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
            <!-- Show a splash screen on the activity. Automatically removed when
                 Flutter draws its first frame -->
            <item name="android:forceDarkAllowed">false</item>
            <item name="android:windowBackground">@drawable/launch_background</item>
        </style>
    </resources>