createCanvasImage method

  1. @override
PCanvasImage createCanvasImage(
  1. Object source, {
  2. int? width,
  3. int? height,
})
override

Creates a PCanvasImage instance compatible to this canvas and its painter.

Implementation

@override
PCanvasImage createCanvasImage(Object source, {int? width, int? height}) {
  var id = ++_imageIdCount;

  if (source is String) {
    var imageElement = ImageElement(src: source, width: width, height: height)
      ..crossOrigin = 'anonymous';
    return _PCanvasImageElement('img_$id', imageElement);
  } else {
    throw ArgumentError("Can't handle image source: $source");
  }
}