-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
When clicking, long-pressing, or dragging a list item, the entire list will undergo a large number of rebuilds, resulting in sluggishness. I don't know if this is normal or a bug. I think the performance can be optimized.
Expectation: If clicking on the list does not trigger the sorting event, the list should not be rebuilt.
AnimatedReorderableListView(
physics: const BouncingScrollPhysics(),
key: GlobalKey(),
dragStartDelay: const Duration(milliseconds: 400),
onReorder: (int oldIndex, int newIndex) {
final Map<PlanEditItemData, int> lockedItemPositions = {
for (int i = 0; i < list.length; i++)
if (lockedItems.contains(list[i])) list[i]: i
};
setState(() {
final PlanEditItemData user = list.removeAt(oldIndex);
list.insert(newIndex, user);
for (var entry in lockedItemPositions.entries) {
list.remove(entry.key);
list.insert(
entry.value,
entry.key); // Insert based on original position (id in this case)
}
});
},
proxyDecorator: proxyDecorator,
itemBuilder: (BuildContext context, int index) {
# HERE ! When touched item or drag item, the list undergoes a large number of rebuild !!!!
print('rebuild !!! ');
return _item(index, context);
},
nonDraggableItems: nonDraggableItems,
lockedItems: lockedItems,
isSameItem: (a, b) => a.id == b.id,
);
Metadata
Metadata
Assignees
Labels
No labels