I want to create a canvas element that I can add to an html document. The Dart recommendations seem to be to use dart:html
rather then dart:dom
, but as far as I can see, dart:html
only contains an interface definition for a CanvasElement
interface, not a class.
How do I instantiate a canvas object?
Eventually you'll be able to just do:
new CanvasElement();
The new HTML lib hasn't been fully populated with constructors yet, though. It's a work-in-progress. In the meantime, the easiest way is probably:
new Element.html('<canvas></canvas>');
That will return an instance of CanvasElement
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With