Convert a CanvasRenderingContext variable for a javascript API

64 views Asked by At

I have a javascript API that takes a canvas context as an argument

The following

var context2dJs = new js.JsObject.fromBrowserObject(canvas.getContext('2d'));

throws Exception: Uncaught Error: object must be an Node, ArrayBuffer, Blob, ImageData, or IDBKeyRange

but the following works

var context2dJs = new js.JsObject.fromBrowserObject(canvas).callMethod('getContext', ['2d']);

However, designing a wrapper around this API, I'd like the dart API to be similar and have a CanvasRenderingContext parameter. How can I convert such dart parameter to its javascript equivalent?

0

There are 0 answers