How to apply external css to html render in flutter webview

4,351

You can submit any JavaScript to your webview by calling :

flutterWebViewPlugin.evalJavascript(js);

In you JavaScript you can add CSS styles using some of the solutions described here. For instance:

// Create our shared stylesheet:
const sheet = new CSSStyleSheet();
sheet.replaceSync('#target {color: darkseagreen}');

// Apply the stylesheet to a document:
document.adoptedStyleSheets = [sheet];
Share:
4,351
Akshata
Author by

Akshata

Updated on November 19, 2022

Comments

  • Akshata
    Akshata over 1 year

    I want to apply external css to html which is render in flutter webview.In android it is done using follwing syntax.

  • satish
    satish over 4 years
    Flutter Does't provide to render complete HTML or CSS, code, you can use WebView, WebView is kind of Web browser which is very expensive widget, it might slow down you app, I would recommend go with widget only.