CreateData constructor

CreateData({
  1. Object? url,
  2. int? tabId,
  3. int? left,
  4. int? top,
  5. int? width,
  6. int? height,
  7. bool? focused,
  8. bool? incognito,
  9. CreateType? type,
  10. WindowState? state,
  11. bool? setSelfAsOpener,
})

Implementation

CreateData({
  /// A URL or array of URLs to open as tabs in the window. Fully-qualified
  /// URLs must include a scheme, e.g., 'http://www.google.com', not
  /// 'www.google.com'. Non-fully-qualified URLs are considered relative
  /// within the extension. Defaults to the New Tab Page.
  Object? url,

  /// The ID of the tab to add to the new window.
  int? tabId,

  /// The number of pixels to position the new window from the left edge of
  /// the screen. If not specified, the new window is offset naturally from
  /// the last focused window. This value is ignored for panels.
  int? left,

  /// The number of pixels to position the new window from the top edge of the
  /// screen. If not specified, the new window is offset naturally from the
  /// last focused window. This value is ignored for panels.
  int? top,

  /// The width in pixels of the new window, including the frame. If not
  /// specified, defaults to a natural width.
  int? width,

  /// The height in pixels of the new window, including the frame. If not
  /// specified, defaults to a natural height.
  int? height,

  /// If `true`, opens an active window. If `false`, opens an inactive window.
  bool? focused,

  /// Whether the new window should be an incognito window.
  bool? incognito,

  /// Specifies what type of browser window to create.
  CreateType? type,

  /// The initial state of the window. The `minimized`, `maximized`, and
  /// `fullscreen` states cannot be combined with `left`, `top`, `width`, or
  /// `height`.
  WindowState? state,

  /// If `true`, the newly-created window's 'window.opener' is set to the
  /// caller and is in the same [unit of related browsing
  /// contexts](https://www.w3.org/TR/html51/browsers.html#unit-of-related-browsing-contexts)
  /// as the caller.
  bool? setSelfAsOpener,
}) : _wrapped = $js.CreateData(
        url: switch (url) {
          String() => url.jsify()!,
          List() => url.toJSArrayString(),
          null => null,
          _ => throw UnsupportedError(
              'Received type: ${url.runtimeType}. Supported types are: String, List<String>')
        },
        tabId: tabId,
        left: left,
        top: top,
        width: width,
        height: height,
        focused: focused,
        incognito: incognito,
        type: type?.toJS,
        state: state?.toJS,
        setSelfAsOpener: setSelfAsOpener,
      );