Adds a composited layer to the recording.
After calling this function, the canvas property will change to refer to a new Canvas that draws on top of the given layer.
A RenderObject that uses this function is very likely to require its RenderObject.alwaysNeedsCompositing property to return true. That informs ancestor render objects that this render object will include a composited layer, which causes them to use composited clips, for example.
Source
void addLayer(Layer layer) { _stopRecordingIfNeeded(); _appendLayer(layer); }