dispose method

void dispose()

Releases the resources associated with this painter.

After disposal this painter is unusable.

Implementation

void dispose() {
  assert(!debugDisposed);
  assert(() {
    _disposed = true;
    return true;
  }());
  // TODO(polina-c): stop duplicating code across disposables
  // https://github.com/flutter/flutter/issues/137435
  if (kFlutterMemoryAllocationsEnabled) {
    FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
  }
  _layoutTemplate?.dispose();
  _layoutTemplate = null;
  _layoutCache?.paragraph.dispose();
  _layoutCache = null;
  _text = null;
}