injectCSSCode method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(), IOSPlatform(), LinuxPlatform(note: 'This method is implemented using JavaScript.'), MacOSPlatform(), WebPlatform(), WindowsPlatform(note: 'This method is implemented using JavaScript.')])
- required String source,
Injects CSS into the WebView.
NOTE: This method shouldn't be called in the PlatformWebViewCreationParams.onWebViewCreated or PlatformWebViewCreationParams.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 PlatformWebViewCreationParams.onLoadStop event or in any other events
where you know the page is ready "enough".
Officially Supported Platforms/Implementations:
- Android WebView
- iOS WKWebView
- Linux WPE WebKit:
- This method is implemented using JavaScript.
- macOS WKWebView
- Web <iframe> but requires same origin
- Windows WebView2:
- This method is implemented using JavaScript.
Parameters - Officially Supported Platforms/Implementations:
source: all platforms
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(),
IOSPlatform(),
LinuxPlatform(note: 'This method is implemented using JavaScript.'),
MacOSPlatform(),
WebPlatform(),
WindowsPlatform(note: 'This method is implemented using JavaScript.'),
],
)
Future<void> injectCSSCode({required String source}) {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.injectCSSCode.name} is not implemented on the current platform',
);
}