screenshot method

Future<Uint8List> screenshot({
  1. ScreenshotFormat? format,
  2. bool? fullPage,
  3. Rectangle<num>? clip,
  4. int? quality,
  5. bool? omitBackground,
  6. bool? captureBeyondViewport,
  7. bool? fromSurface,
})

Parameters:

  • format: Specify screenshot type, can be either ScreenshotFormat.jpeg or ScreenshotFormat.png. Defaults to 'png'.
  • quality: The quality of the image, between 0-100. Not applicable to png images.
  • fullPage: When true, takes a screenshot of the full scrollable page. Defaults to false.
  • clip: a Rectangle which specifies clipping region of the page.
  • omitBackground: Hides default white background and allows capturing screenshots with transparency. Defaults to false.
  • captureBeyondViewport: Capture the screenshot beyond the viewport. When false, cuts the screenshot by the viewport size. Defaults to true.
  • fromSurface: Captures screenshot from the surface rather than the view. When false, works only in headful mode and ignores page viewport (but not browser window's bounds). Defaults to true.

Returns: Future which resolves to a list of bytes with captured screenshot.

NOTE Screenshots take at least 1/6 second on OS X. See https://crbug.com/741689 for discussion.

Implementation

Future<Uint8List> screenshot(
    {ScreenshotFormat? format,
    bool? fullPage,
    Rectangle? clip,
    int? quality,
    bool? omitBackground,
    bool? captureBeyondViewport,
    bool? fromSurface}) async {
  return base64Decode(await screenshotBase64(
      format: format,
      fullPage: fullPage,
      clip: clip,
      quality: quality,
      omitBackground: omitBackground,
      captureBeyondViewport: captureBeyondViewport,
      fromSurface: fromSurface));
}