js-interop: how to implement javascript `new` to dart with js-interop?

Issue

javascript code is..

var terminal = new hterm.Terminal('nike');

I tried to use js-interop

var obj = js.context['hterm']['Terminal'];
var terminal = obj('nike');

but the result is wrong. how to change new keyword from javascript to dart with js-interop?

Solution

With dart:js :

var obj = js.context['hterm']['Terminal'];
var terminal = new js.JsObject(obj,['nike']);

Answered By – Alexandre Ardhuin

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.