How to call a Dart function from Javascript? How to call a Dart function from Javascript? dart dart

How to call a Dart function from Javascript?


You don't need to use new js.JsFunction.withThis. In your case just use :

js.context['myHyperSuperMegaFunction'] = myHyperSuperMegaFunction;

For your information new js.JsFunction.withThis has to be used when you need to use the this Js context. In your error, you can see that the first parameter is Instance of 'Window' which is the global context in Js.