Closed lukehutch closed 8 months ago
OK, I moved this one step further along, by forcing a rebuild of the widget tree using markNeedsBuild
. However, now the pagination widget will shorten the number of items displayed to the new length of the list, when one or more items are deleted, but it just removes widgets from the end of the list, it doesn't check whether the list has changed.
In case anyone else runs into this ussue, I think the solution is to use a unique ValueKey
for each item. However, I wrote my own grid view from scratch, so I'll close this now.
Hi, @lukehutch For insert item into list:
_pagingController.itemList?.insert(0, item);
// ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
_pagingController.notifyListeners();
Hi, @lukehutch For insert item into list:
_pagingController.itemList?.insert(0, item); // ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member _pagingController.notifyListeners();
Do you know how to animate the addition of an item instead of just suddenly appearing?
Do you know how to animate the addition of an item instead of just suddenly appearing?
Yes, you can wrap each item in an ExpandedSection
, and initially hide it by setting expand
to false
, then once it is added to the list, set expand
to true
and call setState
in the parent widget to refresh the UI.
Note that you need to assign each item a unique ValueKey
, otherwise Flutter won't be able to detect when items are added to or removed from the middle of the list, and you'll get some weird behavior.
I need to be able to delete an item from a paginated list, in the middle of one of the pages that has already been fetched.
e.g. for deletion, I tried keeping a copy of all the paginated items fetched so far, in
itemList
, then I filtered this to remove the item that should be deleted, to produceitemListWithItemDeleted
, then I calledHowever, this does not actually update the view. The deleted item is still showing.
What is the purpose of setting the
itemList
, if the view is not going to be updated to reflect the new list?How can I modify the paginated list, after pages have been fetched?
(Ideally this would support both insertion and deletion, but right now I need deletion...)