【发布时间】:2020-02-25 11:42:18
【问题描述】:
这是我的列表视图小部件。有两个列表视图构建器,一个在另一个内部。我添加了 shrinkWrap 属性和物理属性。什么都没有渲染。我对何时使用列表视图、单子滚动视图和自定义滚动视图还有疑问。
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text("Listviews"),
backgroundColor: Colors.blue,
),
body: ListView.builder(
shrinkWrap: true,
itemCount: data == null ? 0 : data.length,
itemBuilder: (BuildContext context, int index) {
if (data[index]["type"] == "single") {
var innerData = data[index]["data"];
return Container(
child: ListView.builder(
shrinkWrap: true,
itemCount: innerData == null ? 0 : innerData.length,
itemBuilder: (BuildContext context, int index) {
String title = innerData[index]["title"];
return Text("$title");
},
),
);
}
},
),
);
}
这是我的 json 响应:
[
{
"type": "single",
"data": [
{
"title": "Fresh Vegetables"
},
{
"title": "Fresh Fruits"
},
{
"title": "Cuts and Sprouts"
},
{
"title": "Exotic Center"
}
]
}
]
我想做像 Flipkart 主页一样。我想根据响应构建小部件。我应该使用哪些小部件?
【问题讨论】:
标签: flutter