I have a for loop, inside of which I have a long if statement. Within that if statement, I have this block:
Right after that if statement (but still within the for loop) I am showing the length of the same list (IDsAlreadyDisplayed) in an Alert. However, it is giving the result as 0, even though the list has 3 items at the same time (I checked this using a ListView)
If I move the Alert.show block to right under the insert in list block, It works perfectly.
Why are the blocks not going in the correct order for the for loop?
Full screenshot: (I have collapsed the if statement as nothing is of relevance, except the above mentioned insert in list block)
You need to show the full statement. You assumed there is no issues with the part you collapsed which means you want us to fucus on what you are focusing on and therefore no one will get a result.
Allow others to see and evaluate the situation you are facing instead of steering them on a specific part that you decided upon.
Meanwhile, insert a wait block before the notifier1 message and if this does not work then move the wait block after the notifier1 message
The burble Get block for the database is asynchronous which means it will not half the app until the operation is completed but will take the requested operation and allow the app to continue processing next block.
This means your alert block will execute before the realtime_DB Get is completed and therefore you might not see any values in the alert message.
If you insert a wait block before getting the length of the list you will give time to the Get block to execute and provide you with results.