captureScreenshot method
Capture page screenshot.
format
Image compression format (defaults to png).
quality
Compression quality from range 0..100
(jpeg only).
clip
Capture the screenshot of a given region only.
fromSurface
Capture the screenshot from the surface, rather than the view. Defaults to true.
captureBeyondViewport
Capture the screenshot beyond the viewport. Defaults to false.
optimizeForSpeed
Optimize image encoding for speed, not for resulting size (defaults to false)
Returns: Base64-encoded image data.
Implementation
Future<String> captureScreenshot(
{@Enum(['jpeg', 'png', 'webp']) String? format,
int? quality,
Viewport? clip,
bool? fromSurface,
bool? captureBeyondViewport,
bool? optimizeForSpeed}) async {
assert(format == null || const ['jpeg', 'png', 'webp'].contains(format));
var result = await _client.send('Page.captureScreenshot', {
if (format != null) 'format': format,
if (quality != null) 'quality': quality,
if (clip != null) 'clip': clip,
if (fromSurface != null) 'fromSurface': fromSurface,
if (captureBeyondViewport != null)
'captureBeyondViewport': captureBeyondViewport,
if (optimizeForSpeed != null) 'optimizeForSpeed': optimizeForSpeed,
});
return result['data'] as String;
}