addTask method

Future<DownloadTask> addTask(
  1. DownloadTask task
)

Adds a new task to the pool, creating a cache directory if needed.

Implementation

Future<DownloadTask> addTask(DownloadTask task) async {
  logV('[DownloadIsolatePool] addTask: ${task.toString()}');
  if (task.cacheDir.isEmpty) {
    String cachePath = await FileExt.createCachePath();
    task.cacheDir = cachePath;
  }
  task.saveFile = task.saveFile;
  _taskList.add(task);
  return task;
}