I have a CustomScrollView
with multiple SliverList
widgets, and I want each SliverList
to act as a DragTarget
. How can I make these lists accept drag-and-drop functionality? Here’s a simplified version of my code where I attempt to wrap each SliverList
in a DragTarget
, but I need guidance on making it work correctly.
What I need help with:
- How can I make each
SliverList
behave as aDragTarget
and accept dragged items? - Is there anything I’m missing to implement this functionality correctly in a
CustomScrollView
?
Code sample
CustomScrollView(
slivers: [
// ...
SliverList.builder(...),
DragTarget<String>(
builder: (context, candidateData, rejectedData) {
return SliverList.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return Text(items[index].name); // Wrapping this widget with DragTarget works, but it's not the desired behavior
},
);
},
),
SliverList.builder(...),
// ...
],
)
New contributor
Albin P K is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.