RenderFlex在底部溢出了40个像素。扑

时间:2020-06-18 06:31:48

标签: flutter

Widget build(BuildContext context) {
   return Card(
      child: ListTile(
         title: new Text(prod_name),
         leading: Image.asset(prod_img, width: 50.0, height: 50.0,),
         subtitle: new Column(
            children: <Widget>[
               new Row(
                 children: <Widget>[
                   Padding(
                     padding: const EdgeInsets.all(0.0),
                     child: new Text("ice-cream: "),
                   ),
                   Padding(
                     padding: const EdgeInsets.all(4.0),
                     child: new Text(prod_ice_cream, style: TextStyle(color: Colors.red),),
                   ),
               ),
               new Container(
                 alignment: Alignment.topLeft,
                 child: new Text("\Rs${prod_price}", style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),),
             ),
             trailing: new Column(
                children: <Widget>[
                   new IconButton(icon: Icon(Icons.arrow_drop_up), onPressed: (){}),
                   new IconButton(icon: Icon(Icons.arrow_drop_down), onPressed: (){})
               ],
             ),
    ),
);

添加这两个图标后,出现“ RenderFlex在底部溢出40个像素” 我尝试了stackoverflow解决方案,但此后,我得到“ RenderFlex底部溢出21个像素”。以下是一些屏幕截图screenshot1 screenshot2 screenshot3。这是我的完整代码code

3 个答案:

答案 0 :(得分:0)

像这样使用 SingleChildScrollView 小部件:

SingleChildScrollView(
          child: your_main_Widget()
) 

答案 1 :(得分:0)

如果“文本”小部件引发溢出错误,则只需将溢出属性设置为“文本”小部件即可。

示例:


Flexible(
  child: new Container(
    padding: new EdgeInsets.only(right: 13.0),
    child: new Text(
      'Your Text Value Here',
      overflow: TextOverflow.ellipsis,

    ),
  ),
),

以下是使用Container而非ListTile的解决方案:


class Single_cart_prod extends StatelessWidget {
  final prod_name;
  final prod_img;
  final prod_price;
  final prod_ice_cream;
  final prod_sugar;

  Single_cart_prod(
      {this.prod_name,
      this.prod_img,
      this.prod_price,
      this.prod_ice_cream,
      this.prod_sugar});
  @override
  Widget build(BuildContext context) {
    return Card(
      child: Container(
        width: double.infinity,
        height: 80,
        child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Expanded(
                flex: 2,
                child: Image.asset(prod_img, width: 50.0, height: 50.0),
              ),
              Expanded(
                flex: 3,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      prod_name,
                      style: TextStyle(
                        fontSize: 16.0,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    Text(
                      "Rs:" + prod_price.toString(),
                      style: TextStyle(
                          fontSize: 16.0,
                          fontWeight: FontWeight.bold,
                          color: Colors.black38),
                    ),
                  ],
                ),
              ),
              Expanded(
                flex: 3,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      "Ice Cream",
                    ),
                    Text(
                      prod_ice_cream,
                      style: TextStyle(color: Colors.red),
                    ),
                  ],
                ),
              ),
              Expanded(
                flex: 3,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      "Sugar",
                    ),
                    Text(
                      prod_sugar,
                      style: TextStyle(color: Colors.red),
                    ),
                  ],
                ),
              ),
              Expanded(
                flex: 1,
                child: Column(
                  children: <Widget>[
                    Expanded(
                        child: IconButton(
                            icon: Icon(Icons.arrow_drop_up), onPressed: () {})),
                    Expanded(
                        child: IconButton(
                            icon: Icon(Icons.arrow_drop_down),
                            onPressed: () {}))
                  ],
                ),
              )
            ]),
      ),
    );
  }
}

输出:

enter image description here

答案 2 :(得分:0)

查看此示例

/usr/bin/php7.4 /mypath/typo3_10/vendor/phpunit/phpunit/phpunit --bootstrap /mypath/typo3_10/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php --configuration /mypath/typo3_10/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml /mypath/typo3_10/web/typo3/sysext/seo --teamcity

让我知道它是否有效