How to change the button icon based on the value of the database?

This is my 3rd question and thanks for previous helps.

In my app the cart should have 2 icons. If the cart is empty the icon should be “Empty cart pic” and if it has something in it the icon should be “Cart with products”.

The problem is, the code i made is working well when i restart the app, but it’s not working when i go beck from ‘ADDING THINGS TO CART’ to ‘DASHBOARD’(This is where the cart button exist).

And i’m little confused between the functions (of screens) Starts & Open.

1 Like

Your code to change the icon should be in the Screen Opens block.

No, it’s not working

1 Like

You need to show your code or create a simple project that demonstrate the issue and share this project someone can have a look and correct it.

Here it is,


Capture

1 Like

This does not provide any clarity.

Use labels inside your code blocks to show what is going on with it.

When testing avoid having two functions running immediately after each other.

If you are deleting a record from your cart table just before switching to the other screen, this could prevent your function from evaluating properly.