openFile method
Implementation
@override
Future<void> openFile(DownloadItem item) async {
try {
final path = item.localPath;
if (path != null && await File(path).exists()) {
final result = await OpenFilex.open(path);
if (result.type != ResultType.done) {
throw Exception('Failed to open file: ${result.message}');
}
} else {
// Attempt opening directly using task ID if local path is null
await FlutterDownloader.open(taskId: item.bgTaskId ?? item.id);
}
} catch (e) {
debugPrint('Error opening file: $e');
}
}