I have a cart listview with an Item component that has a price value and a counter widget for the quantity. I am passing an action to the item component to add/subtract the (quantity * price) of the item to the subtotal variable in the cart page. It is working fine if I only have 1 item in the cart but when there's multiple item, it gets messed up. When I add item1 and item2, then increase the quantity of item1 and then remove it to cart the price being subtracted to the subtotal is (price of item1 * amount of item2) even though the item components have unique key values
in my code expression variable: amount is the quantity of the item taken from the counter value at index of the component
My widget tree structure is this
Listview (generate children from App state integer List (product ids))
Item (backend query fetch specific data from BE using the product id, Unique Key: index in list)
The cart is working fine when there is only 1 item, and it gets messed up is when there's multiple product in it. What might be causing this?