canvas property Null safety

  1. @override
Canvas canvas

The canvas on which to paint.

The current canvas can change whenever you paint a child using this context, which means it's fragile to hold a reference to the canvas returned by this getter.


Canvas get canvas {
  if (_canvas == null) {
  assert(_currentLayer != null);
  return _canvas!;