ReorderableListView inside SingleChildScrollView/Column

Viewed 1588

I need to put my reorderable list inside SingleChildScrollView, but the ReorderableListView() doesn't have shrink wrap like ListView(). Is there a work around to accomplish this layout without using an outdated unmaintained package? Although, I haven't tested those available outdated packages yet I don't know if they're built using different widgets or they're just building upon ReorderableListView() if so the error will persist.

3 Answers

you can wrap your ReorderableListView with Expanded Widget in Column.

For me, I was using a Reorderable Listview inside a Column which was inside an ScrollView.

Tried multiple combinations but was getting the error, so I just wrapped each ListTile of the ListView in a container, and it worked for me. If that doesnt work then try limiting the height of each container.

The flutter team has released 2.0.1 stable recently, which shipped with a new designed ReorderableList class. As I tested, the ReorderableList class can work with Column and SingleChildScrollView smoothly.

code snippet like:

SingleChildScrollView(
  child: Column(
    children: [
      ReorderableList(
              controller: ScrollController(),
              shrinkWrap: true,
              itemCount: itemList.length,
              itemBuilder: (BuildContext context, int index) {
                final item = itemList[index];
                return ReorderableDelayedDragStartListener(
                          index: index,
                          key: UniqueKey(),
                          ListTile(...),
                        );
              },
              onReorder: (int oldIndex, int newIndex) {...},
         ),
       ],
     ),
   );

                
Related