injectCSSFileFromAsset method Null safety

Future<void> injectCSSFileFromAsset(
  1. {required String assetFilePath}
)

Injects a CSS file into the WebView from the flutter assets directory.

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".

Implementation

Future<void> injectCSSFileFromAsset({required String assetFilePath}) async {
  String source = await rootBundle.loadString(assetFilePath);
  await injectCSSCode(source: source);
}