I'm trying out the Dart Language and HTML5 Canvas element, but I'm stuck with one problem. I don't know how to load an image in Dart. I can get CanvasRenderingContext2D and with this I can call fillText() and fillRect() and everything works, but I am trying to figure out how to load an Image and draw with drawImage.
Create and load the image
ImageElement image = new ImageElement(src: "my_image.png");
image.onLoad.listen((e) {
// Draw once the image is loaded
});
Draw the above image on the canvas after it is loaded
context.drawImage(image, destX, destY);
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