close method

Future<void> close()

Implementation

Future<void> close() async {
  await _bestEffortStopActiveRecording();
  final artifacts = _downloadableArtifacts.values.toList(growable: false);
  _downloadableArtifacts.clear();
  for (final artifact in artifacts) {
    final sourceFilePath = artifact.sourceFilePath;
    if (!artifact.deleteOnClose ||
        sourceFilePath == null ||
        sourceFilePath.isEmpty) {
      continue;
    }
    try {
      final file = File(sourceFilePath);
      if (await file.exists()) {
        await file.delete();
      }
    } on Object {
      // Best-effort cleanup only for generated diagnostics artifacts.
    }
  }
}