openWindow static method

JsObject openWindow({
  1. String? name,
  2. String? html,
  3. bool print = false,
})

Opens a new Window.

  • name of the Window.
  • html the Window HTML.
  • print if true will print the window.

Implementation

static JsObject openWindow({String? name, String? html, bool print = false}) {
  var openParams = <dynamic>[];

  if (name != null) {
    if (openParams.isEmpty) {
      openParams.add(null);
    }
    openParams.add(name);
  }

  var w = context.callMethod('open', openParams) as JsObject;

  if (html != null && html.isNotEmpty) {
    var doc = w['document'] as JsObject;
    var body = doc['body'] as JsObject;
    var o = context.callMethod(r'$', [body]) as JsObject;
    o.callMethod('html', [html]);
  }

  if (print) {
    w.callMethod('focus');
    w.callMethod('print');
  }

  return w;
}