dispose method

Future<void> dispose()

Implementation

Future<void> dispose() async {
  if (_isDisposed) return;
  _isDisposed = true;
  _isStreaming = false;
  _isInitializingStream = false;
  _permissionsVerified = false;
  _cachedPermissions = null;

  try {
    _channel?.sink.close();
    _isConnected = false;
  } catch (_) {}

  try {
    if (_commandController != null && !_commandController!.isClosed) {
      await _commandController!.close();
    }
  } catch (_) {}

  try {
    await stopScreenCapture();
  } catch (_) {}

  _cancelInactivityTimer();
  log('✅ RemoteControl disposed');
}