dispose method

  1. @override
void dispose()
override

Releases subscriptions/resources. Called before the screen is unmounted.

Implementation

@override
void dispose() {
  _disposed = true;
  _fitter?.dispose();
  _fitter = null;
  _detachOrientation?.call();
  // Release the page scroll lock and any fullscreen state on the way out.
  web.document.documentElement?.classList.remove('terminal-active');
  if (_fullscreen) {
    web.document.documentElement?.classList.remove('term-fullscreen');
  }
  // Navigating away from a live session detaches it so it stays resumable.
  if (!_finished && _shell != null && !_shell!.ended) {
    _finished = true;
    unawaited(_shell!.detach());
  } else {
    unawaited(_shell?.dispose());
  }
  // Null the terminal so any late `_settle` timer/rAF callback that slips
  // through becomes a no-op rather than touching a disposed terminal.
  final term = _term;
  _term = null;
  term?.dispose();
}