endRecording method Null safety

Picture endRecording()

Finishes recording graphical operations.

Returns a picture containing the graphical operations that have been recorded thus far. After calling this function, both the picture recorder and the canvas objects are invalid and cannot be used further.


Picture endRecording() {
  if (_canvas == null)
    throw StateError('PictureRecorder did not start recording.');
  final Picture picture = Picture._();
  _canvas!._recorder = null;
  _canvas = null;
  return picture;