I’m using Provider in my project, I have big list of custom object (comments), If I have about 1,000 comments in the list, when I update an item in the list, let’s say I like some of comments and changing the isLike
bool from false to true, it rebuilds all the list, because I’m using Selector
in the list, and the notifyListeners
rebuilds all the 1,000 items instead this little like change.
I googled it and didn’t find any example / doc that’s talking about it, all the examples just show how to rebuild all the list widget instead of the specific widget item.
2
Answers
Each of your comments should have a Stateful part called, for example, CommentActions. With it’s own internal state, that could be set initially when you build all your comments by passing the initial values. But the actions such as likes and dislikes should only update it’s own state and do not notify the entire list.
you can change status of selected item locally once you get api response through (indexWhere built-in function):
Hope this help.