takeScreenshot method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(note: 'To be able to take screenshots outside the visible viewport, you must call [PlatformInAppWebViewController.enableSlowWholeDocumentDraw] before any WebViews are created.'), IOSPlatform(apiName: 'WKWebView.takeSnapshot', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot', available: '11.0'), MacOSPlatform(apiName: 'WKWebView.takeSnapshot', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot', available: '10.13'), WindowsPlatform(), LinuxPlatform()])
- ScreenshotConfiguration? screenshotConfiguration,
Takes a screenshot of the WebView's visible viewport and returns a Uint8List. Returns null if it wasn't be able to take it.
screenshotConfiguration represents the configuration data to use when generating an image from a web view’s contents.
Officially Supported Platforms/Implementations:
- Android WebView:
- To be able to take screenshots outside the visible viewport, you must call PlatformInAppWebViewController.enableSlowWholeDocumentDraw before any WebViews are created.
- iOS WKWebView 11.0+ (Official API - WKWebView.takeSnapshot)
- macOS WKWebView 10.13+ (Official API - WKWebView.takeSnapshot)
- Windows WebView2
- Linux WPE WebKit
Parameters - Officially Supported Platforms/Implementations:
screenshotConfiguration: all platforms
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
note:
'To be able to take screenshots outside the visible viewport, you must call [PlatformInAppWebViewController.enableSlowWholeDocumentDraw] before any WebViews are created.',
),
IOSPlatform(
apiName: 'WKWebView.takeSnapshot',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot',
available: '11.0',
),
MacOSPlatform(
apiName: 'WKWebView.takeSnapshot',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot',
available: '10.13',
),
WindowsPlatform(),
LinuxPlatform(),
],
)
Future<Uint8List?> takeScreenshot({
ScreenshotConfiguration? screenshotConfiguration,
}) {
throw UnimplementedError(
'${PlatformInAppWebViewControllerMethod.takeScreenshot.name} is not implemented on the current platform',
);
}