injectCSSCode method

Future<void> injectCSSCode({
  1. required String source,
})

Injects CSS into the WebView.

NOTE: This method shouldn't be called in the WebView.onWebViewCreated or WebView.onLoadStart events, because, in these events, the WebView is not ready to handle it yet. Instead, you should call this method, for example, inside the WebView.onLoadStop event or in any other events where you know the page is ready "enough".

Supported Platforms/Implementations:

  • Android native WebView
  • iOS

Implementation

Future<void> injectCSSCode({required String source}) async {
  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent('source', () => source);
  await _channel.invokeMethod('injectCSSCode', args);
}