I have built a Listview
with ExpansionTile
. But Now I want that if I tap on an ExpansionTile
then only that ExpansionTile
should open and other Expanded ExpansionTile
should close.
Please help me how can I achieve this?
Here is my Code for ExpansionTile
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Short Product"),
),
body: ListView.builder(
itemCount: Category_List.length,
itemBuilder: (context, i) {
return ExpansionTile(
title: Text(Category_List[i].cat_name),
children:_Product_ExpandAble_List_Builder(Category_List[i].cat_id)
);
},
)
);
}
_Product_ExpandAble_List_Builder(int cat_id) {
List<Widget> columnContent = [];
Product_List.forEach((product) => {
columnContent.add(
ListTile(
title: ExpansionTile(
title: Text(product.prod_name),
),
trailing: Text("${product.total_Qty} (Kg)"),
),
),
});
return columnContent;
}
}
Thanks in advance.
ExpansionPanelList.radio
- it does what you want. – Erastianism