繁体   English   中英

ListView.builder 底部在颤动中按像素溢出

[英]ListView.builder bottom overflow by pixel in flutter

这就是我使用ListView.builder ,它是在带有Expanded小部件的Column使用的。 我尝试了一些解决方案,但它们不起作用,这是一个动态列表。

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)),

              ],),)

        ],
      );
    }

尝试使用 SingleChildScrollView 包装容器

尝试给你的 Container 全高像height: MediaQuery.of(context).size.height

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM