dispose method

  1. @override
void dispose()
override

Clears any retained resources that this layer holds.

This method must dispose resources such as EngineLayer and Picture objects. The layer is still usable after this call, but any graphics related resources it holds will need to be recreated.

This method only disposes resources for this layer. For example, if it is a ContainerLayer, it does not dispose resources of any children. However, ContainerLayers do remove any children they have when this method is called, and if this layer was the last holder of a removed child handle, the child may recursively clean up its resources.

This method automatically gets called when all outstanding LayerHandles are disposed. LayerHandle objects are typically held by the parent layer of this layer and any RenderObjects that participated in creating it.

After calling this method, the object is unusable.

Implementation

@override
void dispose() {
  removeAllChildren();
  _callbacks.clear();
  super.dispose();
}