【发布时间】:2020-01-17 05:28:52
【问题描述】:
我有一个扩展图块列表,其中每个都包含一个 ListTile 列表。现在我要做的是在单击一个扩展磁贴时折叠所有扩展。我只想一次展开并显示 一个 展开图块。 或者有什么办法可以将它迁移到扩展面板。
child: Card(
child: ExpansionTile(
key: _expansionKey,
backgroundColor: Colors.black12,
onExpansionChanged: (val) {
setState(() {
preId = prescriptionProvider
.doctorPrescriptions[index]
.prescriptionId;
fetchDoctorPrescriptionDrugsByDoctor(
preId);
});
Toast.show("Changed", context);
},
title: Text("Prescription ID : " +
prescriptionProvider
.doctorPrescriptions[index]
.prescriptionId),
children: <Widget>[
InkWell(
onTap: () {
},
child: ListView.builder(
itemCount: presciptionDrugList.length,
shrinkWrap: true,
itemBuilder:
(BuildContext context, int i) {
return ListTile(
title: Text(
presciptionDrugList.isNotEmpty
? presciptionDrugList[i]
.drugsName
: "loading",
),
trailing: Icon(FontAwesomeIcons.pills),
);
},
),
)
],
),
),
由于我有一个列表数组变量,我在其中获取 ListTile 的数据打开的图块将显示与我正在展开的图块相同的数据。所以,我想通过折叠它们来隐藏它。
【问题讨论】: