delete method
Deletes the temporary file and directory.
This is handled automatically by Context.dispose() 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 {
if (tempDir != null) {
final dir = Directory(tempDir!);
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
}
}