当页面中需要把Listview嵌套到Column或者Row中的时候,如果直接在children中写Listview,
页面是不会显示的这个时候需要将Listview嵌套在一个Container或者SizeBox中指定大小才可以
具体代码如下:
Container(
width: double.infinity,
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: ScreenUtil.getInstance().setHeight(85.0),
padding: EdgeInsets.only(left: 10.0),
alignment: Alignment.centerLeft,
child: Text(
'Hello Flutter',
style: TextStyle(
color: primaryColor,
fontSize: 12.0,
fontWeight: FontWeight.w300),
),
),
Container(
width: double.infinity,
height: ScreenUtil.getInstance().setHeight(460),
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: recommendGoods.length,
itemBuilder: _getListItem,
),
),
],
),
)