dispose method

void dispose()

Dispose and clean up resources

Implementation

void dispose() {
  // Cancel all stream subscriptions first
  _stdoutSubscription?.cancel();
  _stderrSubscription?.cancel();

  // Then close the controllers if they're not already closed
  if (!_outputController.isClosed) {
    _outputController.close();
  }

  if (!_errorController.isClosed) {
    _errorController.close();
  }

  if (!_responseController.isClosed) {
    _responseController.close();
  }
}