delete method
Deletes the temporary file and directory.
This is handled automatically by context disposal if not already called. Safe to call multiple times — subsequent calls are no-ops.
Implementation
Future<void> delete() async {
if (_deleted) return;
_deleted = true;
try {
final dirVal = tempDir;
if (dirVal != null) {
final dir = Directory(dirVal);
if (await dir.exists()) {
await dir.delete(recursive: true);
}
} else {
final file = File(tempPath);
if (await file.exists()) {
await file.delete();
}
}
} catch (_) {
// Best effort cleanup
}
}