How to Create a To Do App & Store the Items in a Stored List

variables
lists
tutorial

#1

Hey Friends!

The Tutorial
I am adding this post under Video Tutorials since the discussion stems from a video tutorial I made on how to create a simple to do / task management app. Here is the original video:

Explanation
Someone tried replicating the app and wanted to enhance it by storing the tasks in a stored / local variable. However, this code was not working.

Original Blocks
Here are the original blocks.

Problem Code
The problem was he was trying to add the input item to a list variable BUT the variable had not been initialized (or defined) as a list.

An Incorrect Solution
Your 1st instinct may be to set the variable to an empty list whenever the screen starts. This does not work because the app ends up clearing out the list every time you close and reopen the app. This defeats the purpose of the stored variable.
Incorrect%20Solution

The Correct Solution
Rather, a better approach is to only set the variable to an empty list IF the list has not yet been defined. This makes the stored variable a list variable IF and ONLY IF the list is not yet defined. Thus it will not clear out any items previously stored in the list.
Added%20Line

The Final Code
These are the final blocks that I got to work.

Let me know if you have a better solution to this - hope this helps you in your troubleshooting in the future! :grinning:

Thanks,

Darren
Thunkable X Tutorials


Buzzword Bingo - Just don't tell the boss you're playing
#2

This is really nice; you guys should update the chat tutorial to be a bit more list this; the current tutorial saves the text onto a single string variable so it’s confusing as to how it could actually be used in a real-life scenario…

also, please fix the WebAPI component (at least on iOS) it simply doesn’t send any headers or body :frowning:
(or maybe I’m doing something wrong and a tutorial using it would help…?)


#3

Hi Darren,
The piece of code worked perfectly!!
Thanks for helping out.

I got the question here if I could put a checkbox on a list…
So you could choose whether you want to check a task or delete it…
Another challange😊


#4

@Dinto has also mentioned wanting a chat app to me before, but I think the list viewer needs some more property features before we could make one.

I think at a minimum, I would want to be able to left or right align different elements in the list viewer, and also add styling like coloring. Currently these features are not available.


#5

@Dinto Glad to hear it. I also do not know of a checkbox feature to make complete.

With the current features available, I would suggest having a “To Do” list and a “Completed List”. And when you click on an item in the To Do List, you could choose to delete or move to the Completed List.


#6

That’s one to try.
There two thing actually;

  1. in one of my list, the Notitie one, if I want to delete an item, it deletes the item I click on, it deles another one. I can’t find the error, it think it’s a bug…

  2. I am Testing the todo-list with two phone.
    When I added an item to a list on one phone, it came up on the other phone. I don’t want to share the todo-list.
    Some one who downloads the app have the possibility to make his or her own list.

I’m now storing the variables in the app ( at first seen in your tutorial in the cloud) How can I get this right?
Regards, Dinto


#7

Hey Dinto!

For #1:
Please share a screenshot of your app or send my a link through direct message.

For #2:
This may be because you are testing in the live app or using a cloud variable when logged into the same account. I would start out with a stored variable. It is really up to you. Read more about variables here: https://docs.thunkable.com/thunkable-cross-platform/create/blocks/variables

Thanks,
Darren


#8

Hi Darren,
It’s been a few day’s ago, busy:sweat_smile:

Still having problems with the issue above;
I have two list, list one: Notitie and list two: Boodschappen.
When I add items to both list, and delete an item on one list, it deletes the item on that list but when I delete another item from the other list, it doesn’t delete the item I touch but the one under that item…
I’ve delete the screens and start over again because thought it could also be a bug in one of the listviewers, didn’t help.
I’ve also change te code a bit, with local storage instead of the use of stored variable.
Could you give it a try?
I wil send you the project link


#9

I believe this is a bug in the Thunkable code. The issue is with list indices, so anytime you are using a list, you may run into this error. See the issue on github here:

This check is currently working for me, so try this approach out:

Happy Coding!
Darren


#10

Hi Darren,
Thanks for your help!:ok_hand:t5:
I am going to try your lines of code…
I will let know if it works for me.
Thnx in regards


#11

Hi Darren,

I Tried you code, and it did work, for 2 days::disappointed_relieved:
I read that it is a bug…
The notitie screen is working, but de Boodschappen screen is now deleting two items at a time.
Or if I tap two times on an item the whole row with 4 items disappears.
This don’t have to be that difficult?
here is the List_viewer code…