【发布时间】:2020-01-03 09:06:05
【问题描述】:
这个 json 有两个数据,第一个只有名称,第二个在里面还有名称,即服务名称。 ex 'Travel and Stay' 和 'Religious' 是必须显示在扩展磁贴名称中的主要名称,而 'Church/Baptism' 和 'Hindu Temples' 是显示在复选框列表磁贴中的子项。希望你能理解 :slightly_smiling_face: 请帮帮我
class _MyHomePageState extends State<MyHomePage> {
var lovCountryServices = [
{
"services": [
{
"service_group_id": 22,
"service_category": "B",
"name": "Air Tickets",
"id": 228
},
{
"service_group_id": 22,
"service_category": "W",
"name": "Boys Hostel",
"id": 229
},
],
"name": "Travel and Stay",
"is_active": true,
"id": 22
},
{
"services": [
{
"service_group_id": 19,
"service_category": "B",
"name": "Church/ Baptism",
"id": 193
},
{
"service_group_id": 19,
"service_category": "B",
"name": "Hindu Temples",
"id": 194
}
],
"name": "Religious",
"is_active": true,
"id": 19
}
];
List<_Result> _results = [];
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
children: <Widget>[
ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(8.0),
itemCount: lovCountryServices.length,
itemBuilder: (BuildContext context, int index) {
var item = lovCountryServices[index];
var items= lovCountryServices[index]['services'];
return ExpansionTile(
title: Text(item['name']),
children: <Widget>[
CheckboxListTile(
title: Text("temp"),
value: item['is_active'],
onChanged: (val) {
setState(() {
item['is_active'] = val;
});
},
),
],
);
},
),
RaisedButton(
onPressed: () => print("sending to backend"),
child: Text("SEND"),
)
],
)),
);
}
}
我想要复选框列表图块中的数据,右侧有一个名为 TEMP 的虚拟数据,我想要来自 json 的数据,现在在 json 中有“男孩旅馆”,此数据需要进入复选框列表图块。希望你不明白请帮助我
【问题讨论】:
标签: json checkbox flutter expandablelistview checkboxlist