trash method

  1. @nonVirtual
void trash(
  1. Cleanup cleanup
)

Defers cleanup until this build stops being current.

The trash is emptied right before every rebuild and once at unmount, so each build cleans up after the one it replaced:

painter = TextPainter(text: span);
trash(painter.dispose);

Emptied most-recent-first, so a teardown that emits must be trashed after the handlers it will notify.

Implementation

@nonVirtual
void trash(Cleanup cleanup) {
  (_cleanups ??= []).add(cleanup);
}