0
我是新來的顫抖,我陷入了一個問題。我正在嘗試製作擴展小組列表。我能夠製作列表,但無法使擴展面板展開或摺疊。我附上代碼。請看看它,讓我知道這個問題。顫動中的擴展面板列表
ExpansionPanelList criteria;
criteria = new ExpansionPanelList(
children: <ExpansionPanel>[
new ExpansionPanel(
headerBuilder: schoolheaderBuilder,
body: new Text("school"),
isExpanded: false,
),
new ExpansionPanel(
headerBuilder: hospitalheaderBuilder,
body: new Text("hospital"),
),
new ExpansionPanel(
headerBuilder: vaheaderBuilder,
body: new Text("va facility"),
isExpanded: false),
new ExpansionPanel(
headerBuilder: restheaderBuilder,
body: new Text("Restaurants"),
isExpanded: false),
new ExpansionPanel(
headerBuilder: crimeheaderBuilder,
body: new Text("Crime"),
isExpanded: false),
new ExpansionPanel(
headerBuilder: commuteheaderBuilder,
body: new Text("Commute"),
isExpanded: false),
new ExpansionPanel(
headerBuilder: incomeBuilder,
body: new Text("Household Income"),
isExpanded: false),
new ExpansionPanel(
headerBuilder: househeaderBuilder,
body: new Text("House Value"),
isExpanded: false)
],
expansionCallback: (int index, bool isExpanded)
{
isExpanded = !criteria.children[index].isExpanded;
},
);
你可以嘗試切換isExpanded與criteria.children ...?像這樣: criteria.children [index] .isExpanded =!isExpanded; –
有人給我說:https://stackoverflow.com/questions/45104182/cant-creat-expansionpanellist-with-items-in-flutter/45104992#45104992 –
檢查[這個例子](https://github.com/ flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart)來自flutter gallery – Himanshu