philip-brink / DragAndDropLists

Flutter package for drag-and-drop reordering of two-level lists
BSD 3-Clause "New" or "Revised" License
253 stars 128 forks source link

Unable to put DragAndDropLists as a child of ListView #20

Closed kinex closed 3 years ago

kinex commented 3 years ago

If DragAndDropLists is put under a parent ListView, the following exception is thrown:

I/flutter ( 9482): The following assertion was thrown during performResize():
I/flutter ( 9482): Vertical viewport was given unbounded height.
I/flutter ( 9482): Viewports expand in the scrolling direction to fill their container. In this case, a vertical
I/flutter ( 9482): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter ( 9482): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter ( 9482): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter ( 9482): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter ( 9482): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter ( 9482): the height of the viewport to the sum of the heights of its children.
I/flutter ( 9482):
I/flutter ( 9482): The relevant error-causing widget was:
I/flutter ( 9482):   DragAndDropLists

I checked from code that DragAndDropLists uses internally ListView. If you expose ListView.shrinkWrap this issue can be avoided. Other (maybe better) option would be to use Column instead of ListView when DragAndDropLists.disableScrolling is true.

Workaround is to wrap DragAndDropLists to a Container with correct height, but it is very difficult to calculate the correct height of the Container if all items should be visible.

philip-brink commented 3 years ago

Hi @kinex, thanks for the comment. I've used your idea for returning a Column instead of a ListView. It's included in v. 0.2.10.

kinex commented 3 years ago

Thanks, works great now!

DanielHentschel commented 2 years ago

Hi @philip-brink, i'm trying to implement the same as above. The problem for me is that the list that item is removed from shrinks from the top instead from bottom. How do I prevent this? kind regards Daniel