这就是我使用ListView.builder
的方式,它是在Column
和Expanded
小部件中使用的。我已经尝试了一些解决方案,但是它们不起作用,这是一个动态列表。
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
headingContainer(width,order_response),
Expanded(
child: ListView.builder(
shrinkWrap: true,
controller: _scrollController,
itemCount:order_response.orderDetails.length,
itemBuilder: (context, position) {return orderListItemTile(width,height,order_response,position);},
),
),
],
),
);
Column orderListItemTile(double width,double height, Order order_response, int position){
return Column(
children: <Widget>[
GestureDetector(
onTap: (){
Navigator.push(
context,
new MaterialPageRoute(builder: (context) => new OrderDetails(payload:order_response.orderDetails[position].orderRowId)),
);
},
child: new Container(
decoration: BoxDecoration(color: MyColors.backgroundColor),
padding: EdgeInsets.only(left:width*0.05,right: width*0.05,top:width*0.03,bottom: width*0.03),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(order_response.orderDetails[position].orderDateTime,style: TextStyle(color: Colors.grey,fontSize: 14.0,fontWeight: FontWeight.w800)),
SizedBox(height: height*0.01),
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(order_response.orderDetails[position].productName,style: TextStyle(color: MyColors.colorPrimaryDark,fontSize: 18.0,fontWeight: FontWeight.w700)),
SizedBox(
height: 26.0,
width: 26.0,
child: RawMaterialButton(
onPressed: () {
},
child: new Icon(
Icons.arrow_forward_ios,
color: Colors.white,
size: 16.0,
),
shape: new CircleBorder(),
elevation: 2.0,
fillColor: Colors.grey[400],
padding: const EdgeInsets.all(5.0),
),
),
],
),
SizedBox(height: height*0.01),
Text(order_response.orderDetails[position].customerName,style: TextStyle(color: Colors.grey,fontSize: 14.0,fontWeight: FontWeight.w800)),
],
),
),),
Container(
decoration: BoxDecoration(color: Colors.grey[350]),
padding: EdgeInsets.only(left:width*0.05,right: width*0.05),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
SizedBox(
height: 36.0,
width: 36.0,
child: IconButton(
padding: EdgeInsets.only(top:4.0,bottom: 4.0),
icon: Image.asset(order_response.orderDetails[position].orderStatus.contains('accepted')?'assets/images/right.png':'assets/images/wrong.png'),
onPressed: (){Navigator.pop(context,true);}
)),
SizedBox(
height: 36.0,
width: 36.0,
child: IconButton(
padding: EdgeInsets.only(top:4.0,bottom: 4.0,left: 5.0),
icon: Image.asset('assets/images/cart.png'),
onPressed: (){Navigator.pop(context,true);}
)),
],),
Text('Total ${order_response.orderDetails[position].orderAmount}',style: TextStyle(color: Colors.black87,fontSize: 16.0,fontWeight: FontWeight.w700)),
],),)
],
);
}
答案 0 :(得分:0)
尝试使用SingleChildScrollView包装容器
答案 1 :(得分:0)
尝试使容器的高度像height: MediaQuery.of(context).size.height