I want to make a ReordableListView containing several ExpansionTile but it doesn’t work, the ExpansionTile doesn’t open.
If I put the parameter buildDefaultDragHandles: false the ExpansionTile opens but the gesture for reordering the list no longer works.
How can I join the reorder gesture with ExpansionTile without affecting each other?
class Test extends StatefulWidget {
const Test({super.key});
@override
State<Test> createState() => _TestState();
}
class _TestState extends State<Test> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: ReorderableListView.builder(
//buildDefaultDragHandles: false,
itemBuilder: (context, index) {
return ExpansionTile(
key: GlobalKey(),
title: Container(
height: 70.0,
color: Colors.blue,
),
children: [
Container(
height: 30.0,
color: Colors.green,
),
],
);
},
itemCount: 10,
onReorder: (oldIndex, newIndex) {},
),
),
);
}
}
2
Answers
Having ExpansionTile leading and
ReorderableListView
handler at same place is kinda bad ux i think, you can have it like row or change one to the leadingYou can do
I’m wondering it would work if you wrap the container with a Dismissible widget so that you can swipe to remove the item