List<int> stateItems = <int>[
1, 1, 2, 2, 0, 1, 1, 1, 0, 1, 2, 2, 1, 2,
];
List<String> strItems = <String>[
'图标 -> keyboard', '图标 -> print', '图标 -> router',
'图标 -> pages', '图标 -> zoom_out_map', '图标 -> zoom_out',
'图标 -> youtube_searched_for', '图标 -> wifi_tethering', '图标 -> wifi_lock',
'图标 -> widgets', '图标 -> weekend', '图标 -> web', '图标 -> accessible', '图标 -> ac_unit',
];
List<Icon> iconItems = <Icon>[
new Icon(Icons.keyboard), new Icon(Icons.print), new Icon(Icons.router),
new Icon(Icons.pages), new Icon(Icons.zoom_out_map), new Icon(Icons.zoom_out),
new Icon(Icons.youtube_searched_for), new Icon(Icons.wifi_tethering), new Icon(Icons.wifi_lock),
new Icon(Icons.widgets), new Icon(Icons.weekend), new Icon(Icons.web),
new Icon(Icons.accessible), new Icon(Icons.ac_unit),
];
Widget buildListData(
BuildContext context, String strItem, Icon iconItem, int type) {
Widget widget;
switch (type) {
case 1:
widget = new ListTile(
isThreeLine: false,
leading: iconItem,
title: new Text(strItem),
trailing: new Icon(Icons.keyboard_arrow_right),
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return new AlertDialog(
title: new Text(
'ListViewDemo',
style: new TextStyle(
color: Colors.black54,
fontSize: 18.0,
),
),
content: new Text('您选择的item内容为:$strItem,item 状态为 1'),
);
},
);
},
);
break;
case 2:
Widget wi;
if ('图标 -> pages' == strItem) {
wi = new Container(height: 0.0, width: 0.0);
} else {
wi = new Text(
strItem,
style: new TextStyle(color: Colors.blueAccent, fontSize: 18.0),
);
}
widget = new GestureDetector(
child: new Column(
children: <Widget>[
iconItem,
wi,
],
),
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return new AlertDialog(
title: new Text(
'ListViewDemo',
style: new TextStyle(
color: Colors.black54,
fontSize: 18.0,
),
),
content: new Text('您选择的item内容为:$strItem,item 状态为 2'),
);
},
);
},
);
break;
default:
widget = new Container(
height: 50.0,
color: Colors.greenAccent,
child: new Padding(
padding: new EdgeInsets.all(12.0),
child: new GestureDetector(
child: new Text('我是状态为0的item'),
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return new AlertDialog(
title: new Text(
'ListViewDemo',
style: new TextStyle(
color: Colors.black54,
fontSize: 18.0,
),
),
content: new Text('哈哈哈!当前 item 状态为 0'),
);
},
);
},
),
),
);
break;
}
return widget;
}
评论