解决方式如下:
@override
Widget build(BuildContext context) {
return Container(
child: ListView(
children: <Widget>[
_topSearchView(),
_listView()
],
),
);
}
Widget _topSearchView(){
return Container(
width: ScreenUtil().setWidth(750),
height: ScreenUtil().setHeight(80),
padding: EdgeInsets.all(10),
margin: EdgeInsets.fromLTRB(10, 5, 5, 10),
decoration: BoxDecoration(
color:Colors.white,
borderRadius: BorderRadius.circular((10.0)),
border: Border.all(
width:0.5,color:Colors.black12,
)
),
child: Row(
children: <Widget>[
Icon(Icons.search),
Text('搜索')
],
)
);
}
Widget _listView(){
return Container(
child: ListView.builder(
shrinkWrap: true, //为true可以解决子控件必须设置高度的问题
physics:NeverScrollableScrollPhysics(),//禁用滑动事件
itemCount: 10,
itemBuilder: (context,index){
return _item(context,index);
},
),
);
}
shrinkWrap: true, //为true可以解决子控件必须设置高度的问题
physics:NeverScrollableScrollPhysics(),//禁用滑动事件