dispose method

  1. @override
  2. @mustCallSuper
void dispose()
override

Called when its corresponding element disposed

Implementation

@override
@mustCallSuper
void dispose() {
  _disposed = true;
  super.dispose();

  // Dispose scroll behavior
  disposeScrollable();

  // Clear all paint layers
  _colorFilterLayer.layer = null;
  _imageFilterLayer.layer = null;
  disposeTransformLayer();
  disposeOpacityLayer();
  disposeIntersectionObserverLayer();

  // Dispose box decoration painter.
  disposePainter();
  // Evict render decoration image cache.
  renderStyle.backgroundImage?.image?.evict();
}