Remove list item: Attempt to remove item 1 of an empty list

Hello, I’m creating an application with a horizontal calendar that comes with a task manager.

In the application, the user can add a task with a name, description and date. I am using tinydb as a database along with the horizontal calendar extension.

The problem is that I was creating an option where the user could delete the task just by holding on it, but it was showing the following error

Error:
image

Code: