setDeviceMetricsOverride method

  1. @Deprecated('This command is deprecated')
Future<void> setDeviceMetricsOverride(
  1. int width,
  2. int height,
  3. num deviceScaleFactor,
  4. bool mobile, {
  5. num? scale,
  6. int? screenWidth,
  7. int? screenHeight,
  8. int? positionX,
  9. int? positionY,
  10. bool? dontSetVisibleSize,
  11. ScreenOrientation? screenOrientation,
  12. Viewport? viewport,
})

Overrides the values of device screen dimensions (window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media query results). width Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. height Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. deviceScaleFactor Overriding device scale factor value. 0 disables the override. mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. scale Scale to apply to resulting view image. screenWidth Overriding screen width value in pixels (minimum 0, maximum 10000000). screenHeight Overriding screen height value in pixels (minimum 0, maximum 10000000). positionX Overriding view X position on screen in pixels (minimum 0, maximum 10000000). positionY Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). dontSetVisibleSize Do not set visible view size, rely upon explicit setVisibleSize call. screenOrientation Screen orientation override. viewport The viewport dimensions and scale. If not set, the override is cleared.

Implementation

@Deprecated('This command is deprecated')
Future<void> setDeviceMetricsOverride(
    int width, int height, num deviceScaleFactor, bool mobile,
    {num? scale,
    int? screenWidth,
    int? screenHeight,
    int? positionX,
    int? positionY,
    bool? dontSetVisibleSize,
    emulation.ScreenOrientation? screenOrientation,
    Viewport? viewport}) async {
  await _client.send('Page.setDeviceMetricsOverride', {
    'width': width,
    'height': height,
    'deviceScaleFactor': deviceScaleFactor,
    'mobile': mobile,
    if (scale != null) 'scale': scale,
    if (screenWidth != null) 'screenWidth': screenWidth,
    if (screenHeight != null) 'screenHeight': screenHeight,
    if (positionX != null) 'positionX': positionX,
    if (positionY != null) 'positionY': positionY,
    if (dontSetVisibleSize != null) 'dontSetVisibleSize': dontSetVisibleSize,
    if (screenOrientation != null) 'screenOrientation': screenOrientation,
    if (viewport != null) 'viewport': viewport,
  });
}