dispose method

void dispose()

Clears resources and restores terminal hardware state if modified.

Implementation

void dispose() {
  TermuiBinding.unregister(this);
  _isDisposed = true;
  _eventsSubscription?.cancel();
  _eventsSubscription = null;
  _sizeSubscription?.cancel();
  _sizeSubscription = null;
  _debugTouchTimer?.cancel();

  if (_lastShowsCursor == false) {
    terminal.showCursor();
  }
  if (_lastWantsMouseTracking == true) {
    terminal.disableMouseTracking();
  }
  for (final layer in layers) {
    layer.renderer.dispose();
  }
  layers.clear();
  _lastRequestedSizes.clear();
  focusedLayer = null;
  _draggingLayer = null;
  _capturedMouseLayer = null;
  _globalMouseX = null;
  _globalMouseY = null;
  _isGlobalMouseDown = false;
  _renderer = null;
  _targetBuffer = null;
}