Closed ziasultan2 closed 4 years ago
.value
properties. In fact, you should avoid using the .value in Lists and Maps as much as possible.[index].quantity++;
gives me the impression that you are trying to change the food property, not the list, since there is no "quantity" property in Lists. If you want this property to be Observable, it must also be an observable value.I am closing this issue because it does not contain a case of reproduction, and because it is an inappropriate use of the library. If you think this is really a bug, open another issue with a valid reproduction case, but first, read the documentation above, and check if really what you are facing is a bug, before opening an issue. Community channels are the fastest place for you to ask questions like this.
just to complete the issue, since have a observable list usually is not the best, you should instead have a normal list of observable values:
//before:
final cart = List<Foods>().obs;
//after
final cart = List<Rx<Foods>>();
that way you have a list with multiple observable food classes
and to update them:
cart[index].update( (food) { // this parameter is the class itself that you want to update
food.quantity++;
});
coincidence or not, the documentation about this were added today! https://github.com/jonataslaw/getx/blob/master/docs/en_US/state_management.md#note-about-lists
Thank you dear for this solution.
On Sat, Aug 29, 2020 at 11:53 PM Nipodemos notifications@github.com wrote:
just to complete the issue, since have a observable list usually is not the best, you should instead have a normal list of observable values:
//before:final cart = List
().obs; //afterfinal cart = List<Rx >(); that way you have a list with multiple observable food classes
and to update them:
cart[index].update( (food) { // this parameter is the class itself that you want to update food.quantity++; });
coincidence or not, the documentation about this were added today!
https://github.com/jonataslaw/getx/blob/master/docs/en_US/state_management.md#note-about-lists
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jonataslaw/getx/issues/527#issuecomment-683322444, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQSUSCARASZZLZXAC5XP53SDE6CTANCNFSM4QPBBRWQ .
Fill in the template. Issues that do not respect the model will be closed.
Describe the bug How can I update specific value inside view
Expected behavior update data in listview
Minimal reproduce code Provide a minimum reproduction code for the problem
I tried cart.update() but it's not showing any relevant method to update list