createCanvasElement function

  1. @Deprecated('Use the HTMLCanvasElement constructor instead.')
HTMLCanvasElement createCanvasElement({
  1. int? width,
  2. int? height,
})

Create an HTMLCanvasElement in the current document.

Deprecated in favor of creating the element like other HTML elements:

final canvas = document.createElement('canvas') as HTMLCanvasElement
  ..width = 256
  ..height = 256;

Implementation

@Deprecated('Use the HTMLCanvasElement constructor instead.')
HTMLCanvasElement createCanvasElement({int? width, int? height}) {
  final result = document.createElement('canvas') as HTMLCanvasElement;
  if (width != null) result.width = width;
  if (height != null) result.height = height;
  return result;
}