0

Currently i have a cart application and use hive package to save data cart on memory. When i use normally the app, the quantity of cart show properly grouped. These is the code for deduplicate the items and show their quantity grouped

Map productsQuantity(List<Product> localProducts) {
var result =  {};

for (var singleProduct in localProducts) {
  if (!result.containsKey(singleProduct)) {
    result[singleProduct] = 1;
  } else {
    result[singleProduct] += 1;
  }
}

return result;

}

It's works fine ... but when i refresh the page the items are ungrouped

Before refresh the page, the cart show 5 items and this is expected

2 items of X product

3 items of Y product

After refresh this is the output:

1 item X

1 item X

1 item Y

1 item Y

1 item Y

shroot91
  • 41
  • 1
  • 4

0 Answers0