Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 在颤振应用程序中,右侧的renderflex溢流7px_Flutter_Flutter Layout_Mobile Application_Flutter Dependencies_Flutter Test - Fatal编程技术网

Flutter 在颤振应用程序中,右侧的renderflex溢流7px

Flutter 在颤振应用程序中,右侧的renderflex溢流7px,flutter,flutter-layout,mobile-application,flutter-dependencies,flutter-test,Flutter,Flutter Layout,Mobile Application,Flutter Dependencies,Flutter Test,请帮助我解决颤振应用程序中的此错误。我不知道我做错了什么这是我下面的代码:这是下面的代码。请帮助我 import 'package:flutter/material.dart'; class CartProducts extends StatefulWidget { @override _CartProductsState createState() => _CartProductsState(); } class _Cart

请帮助我解决颤振应用程序中的此错误。我不知道我做错了什么这是我下面的代码:这是下面的代码。请帮助我

     import 'package:flutter/material.dart';

    class CartProducts  extends StatefulWidget {
      @override
      _CartProductsState createState() => _CartProductsState();
    }

    class _CartProductsState extends State<CartProducts> {

      var productsOnTheCart=[
        {
          "name":"Blazer",
          "picture":"images/products/blazer1.jpeg",
          "price":85,
          "size":"M",
          "color":"Black",
          "quantity":1,
        },
         {
          "name":"M Pant",
          "picture":"images/products/pants2.jpeg",
          "price": 80,
          "size":"8",
          "color":"Black",
          "quantity":1,
        },
        {
        "name":"Red Dress",
          "picture":"images/products/dress1.jpeg",
          "price":50,
          "size":"7",
          "color":"Red",
          "quantity":2,

        } 
        ];
      @override
      Widget build(BuildContext context) {
       return ListView.builder(
         itemCount: productsOnTheCart.length,

         itemBuilder: (context, index){
           return new SingleCartProduct(
             cartProdName:productsOnTheCart[index]['name'],
             cartProdColor:productsOnTheCart[index]['color'],
             cartProdQty:productsOnTheCart[index]['quantity'],
             cartProdSize:productsOnTheCart[index]['size'],
             cartProdPrice:productsOnTheCart[index]['price'],
             cartProdPicture:productsOnTheCart[index]['picture'],
           );
         }
       );  
         }
    }

    class SingleCartProduct extends StatelessWidget {

      final cartProdName;
      final cartProdPicture;
       final cartProdPrice;
       final cartProdSize;
       final cartProdColor;
       final cartProdQty;

      SingleCartProduct({
       this.cartProdName,
       this.cartProdPicture,
       this.cartProdPrice,
       this.cartProdSize,
       this.cartProdColor,
       this.cartProdQty});

      @override
      Widget build(BuildContext context) {
        return Card(
          child: ListTile(
            //leading section image section here
            leading: new Image.asset(cartProdPicture, height:80.0,width: 80.0,),
            //title section here
            title: new Text(cartProdName),
            //subtitle section
            subtitle: new Column(
              children: <Widget>[
                //Row Inside Column
                new Row(
                  children: <Widget>[
                    //this section is for the size of the products
                     new Padding(padding:const EdgeInsets.all(4.0),
                child:  new Text("Size:"),
                  ),
                    new Padding(padding: const EdgeInsets.all(4.0),
                child:  new Text(cartProdSize, style: TextStyle(color: Colors.red),),
                  ),
                  //This Section is for Prodcut  Color
                  new Padding(padding:const EdgeInsets.fromLTRB(20.0, 8.0, 8.0, 8.0),
                  child: new Text("Color:"),),
                    new Padding(padding:const EdgeInsets.all(4.0),
                child:  new Text(cartProdColor, style: TextStyle(color: Colors.red),),
                  ),
                  ],
                ),
              new Container(
                alignment: Alignment.topLeft,
                child: new Text("\$${cartProdPrice}",
                 style: TextStyle(
                   fontSize: 17.0, fontWeight: FontWeight.bold, color: Colors.red
                   ),
                 ),
              ) 
                //This Section is for the product price
              ],
            ),
           /* trailing:new Column(
              children: <Widget>[
              new   IconButton(
                icon: Icon(
                  Icons.arrow_drop_up,color: Colors.red),
                  iconSize: 38,onPressed: () {}),
                new IconButton(
                  icon: Icon(
                    Icons.arrow_drop_down,color: Colors.red,),
                    iconSize: 38, onPressed: () {}),

              ],
            )*/
            trailing: FittedBox(
              fit: BoxFit.fill,
              child: Column(
              children: <Widget>[
                new IconButton(icon: Icon(Icons.arrow_drop_up), onPressed: (){}),
                new Text("$cartProdQty", style: TextStyle(fontWeight: FontWeight.bold),),
                new IconButton(icon: Icon(Icons.arrow_drop_down), onPressed: (){}),
              ],
              ),
            ),

          ),
        );
      }

    }
导入“包装:颤振/材料.省道”;
类CartProducts扩展了StatefulWidget{
@凌驾
_CartProductsState createState()=>\u CartProductsState();
}
类_CartProductsState扩展状态{
生产过程中的var=[
{
“名称”:“Blazer”,
“图片”:“图片/产品/blazer1.jpeg”,
“价格”:85,
“尺寸”:“M”,
“颜色”:“黑色”,
“数量”:1,
},
{
“名称”:“M裤”,
“图片”:“图片/产品/pants2.jpeg”,
“价格”:80,
“大小”:“8”,
“颜色”:“黑色”,
“数量”:1,
},
{
“姓名”:“红色连衣裙”,
“图片”:“图片/产品/dress1.jpeg”,
“价格”:50,
“大小”:“7”,
“颜色”:“红色”,
“数量”:2,
} 
];
@凌驾
小部件构建(构建上下文){
返回ListView.builder(
itemCount:productsOnTheCart.length,
itemBuilder:(上下文,索引){
退回新产品(
cartProdName:PRODUCTS零件[index]['name'],
cartProdColor:Cart[索引]['color']中的产品,
cartProdQty:Cart[索引][“数量”]中的产品,
cartProdSize:Cart[索引]['size']中的产品,
cartProdPrice:Cart[索引][“价格”]中的产品,
cartProdPicture:Cart[索引]['picture']中的产品,
);
}
);  
}
}
类SingleCartProduct扩展了无状态小部件{
最终决定;
最终照片;
最终价格;
最终尺寸;
最终颜色;
最终产品数量;
单车产品({
这个.cartProdName,
这张照片,
这个价格,
这个尺寸,
这种颜色,
此参数为.cartProdQty});
@凌驾
小部件构建(构建上下文){
回程卡(
孩子:ListTile(
//前导部分图片部分在这里
前导:新图像。资源(cartProdPicture,高度:80.0,宽度:80.0,),
//标题部分在这里
标题:新文本(cartProdName),
//副标题部分
副标题:新专栏(
儿童:[
//列内行
新行(
儿童:[
//本节介绍产品的尺寸
新填充(填充:常量边集所有(4.0),
子项:新文本(“大小:”),
),
新填充(填充:常量边集所有(4.0),
子项:新文本(cartProdSize,样式:TextStyle(颜色:Colors.red)),
),
//本节介绍产品切割颜色
新填充(填充:从LTRB(20.0,8.0,8.0,8.0,8.0)开始的常量边缘集),
子项:新文本(“颜色:”,),
新填充(填充:常量边集所有(4.0),
子项:新文本(cartProdColor,样式:TextStyle(颜色:Colors.red)),
),
],
),
新容器(
对齐:alignment.topLeft,
子项:新文本(\${cartProdPrice}),
样式:TextStyle(
fontSize:17.0,fontWeight:fontWeight.bold,颜色:Colors.red
),
),
) 
//本节介绍产品价格
],
),
/*尾随:新列(
儿童:[
新图标按钮(
图标:图标(
图标。箭头下拉,颜色:颜色。红色),
iconSize:38,按下:({}),
新图标按钮(
图标:图标(
图标。箭头下拉,颜色:Colors.red,),
iconSize:38,按下:({}),
],
)*/
拖尾:装配箱(
fit:BoxFit.fill,
子:列(
儿童:[
新图标按钮(图标:图标(图标。箭头下拉),按下:({}),
新文本($cartProdQty),样式:TextStyle(fontWeight:fontWeight.bold),
新图标按钮(图标:图标(图标。箭头下拉),按下:({}),
],
),
),
),
);
}
}

如果我记得最近,在
ListView.Builder中应用了
shrinkWrap:true
应该强制视图与它相适应。 我的猜测是listview中的视图导致了溢出

编辑: 溢出可能是由单个购物车小部件内部的
列小部件
引起的。
也许将其切换到
Listview.builder
可能会有所帮助?

如果我记得最近,在
Listview.builder中应用
shrinkWrap:true
应该强制视图与它相适应。 我的猜测是listview中的视图导致了溢出

编辑: 溢出可能是由单个购物车小部件内部的
列小部件
引起的。
也许将其切换到
列表视图.builder
可能会有所帮助?

我猜行小部件中正在发生溢出。 这里有一个解决方案。使用或基于需求

    Padding(
      padding: const EdgeInsets.symmetric(horizontal: 22.0, vertical: 8.0),
      child: Row(
        children: <Widget>[
          Flexible(
            fit: FlexFit.loose, // It means that the child widget can expand to maximum size available thus taking up all space else it can shrink if there is no space available // Refer to the link for more info
            child: Text(
              'This is my first label:',
              style: Theme.of(context).textTheme.subtitle,
            ),
          ),
          SizedBox(width: 5,), // You can simply put some sized boxes like this to have some fixed space instead of wrapping every child in a padding widget
          Flexible(
            fit: FlexFit.loose,
            child: Text(
              'This is my first value',
              style: Theme.of(context).textTheme.body1,
            ),
          ),
          Flexible(
            fit: FlexFit.loose,
            child: Text(
              'This is my second label:',
              style: Theme.of(context).textTheme.subtitle,
            ),
          ),
          SizedBox(width: 5,),
          Flexible(
            fit: FlexFit.loose,
            child: Text(
              'This is my second value',
              style: Theme.of(context).textTheme.body1,
            ),
          ),
        ],
      ),
    ),
填充(
填充:常量边集。对称(水平:22.0,垂直:8.0),
孩子:排(
儿童:[
灵活的(
fit:FlexFit.loose,//这意味着子小部件可以扩展到可用的最大大小,从而占用所有空间,如果没有可用空间,则它可以收缩//有关详细信息,请参阅链接
子:文本(