dispose method

Future<void> dispose()

Implementation

Future<void> dispose() async {
  await breakpoints.dispose();
  _disposed = true;
  if (showTouches) await _setSystemTouches(false);
  final rt = runtime;
  if (showTouches && rt != null && rt.isAttached) {
    try {
      await AppAgent.of(rt)?.setTouches(false).timeout(const Duration(seconds: 2));
    } on Object {
      // best-effort; the app may already be gone
    }
  }
  final rec = activeRecording;
  activeRecording = null;
  if (rec != null) {
    try {
      await rec.stop();
    } on Object {
      // best-effort; the recorder process is killed with our children anyway
    }
  }
  await _teardownRuntime();
  httpFailures.dispose();
  await _errorAlerts?.cancel();
  errors.dispose();
  await _alerts.close();
  await backend.close();
  captures.clear();
}