Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a canvas element in Dart?

Tags:

html

canvas

dart

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?

like image 492
Curyous Avatar asked Nov 24 '11 01:11

Curyous


1 Answers

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.

like image 167
munificent Avatar answered Sep 18 '22 15:09

munificent