execute method

Result<Task> execute(
  1. KanbanColumn doneColumn,
  2. int index
)

Deletes a single task from the Done column.

Notifies listeners with a TaskRemovedEvent when successful. Returns a Result containing the removed task.

Parameters:

  • doneColumn: The Done column
  • index: The index of the task to delete

Implementation

Result<Task> execute(KanbanColumn doneColumn, int index) {
  try {
    if (!doneColumn.isDoneColumn()) {
      throw OperationLimitedToDoneColumnException();
    }
    final removed = doneColumn.deleteTask(index);
    EventNotifier().notify(TaskRemovedEvent(removed, doneColumn));
    return Success(removed);
  } on OperationLimitedToDoneColumnException catch (e) {
    return Failure(e.message);
  } catch (e) {
    throw TaskOperationException('Failed to delete task: ${e.toString()}');
  }
}