Create a to-do list app that can help you to get all the tasks out of your head and manage them on your phone anytime.
Label, Horizontal Arrangement, Button, ListView, TinyDB
First, create a variable named items to store our list of to-do items. We are not able to add or remove item from list stored in tinyDB, hence we will perform the operation on items variable prior saving the list into tinyDB.
When the app screen initialized, we will get first get the value stored in tinyDB and assign it to our items variable. If no value exists in tinyDB, we assign it with an empty list. Then, update the ListView with value of items.
To add an item, first we add the user’s input in the textbox to our items variable. Then, store the value to tinyDB and update the ListView with the lastest list:
Remove Individual Item
To remove the selected item, we remove the item in items based on the index of selected item in our ListView. Then, we store the items to tinyDB and update the ListView:
Remove All Items
To remove all items in list, all we need to do is to set our items to an empty list. Again, we store the empty list to tinyDB and update the ListView:
- Ask for confirmation prior clearing all the items