首页 > 解决方案 > 被 18 像素抖动溢出

问题描述

溢出 18 个像素的 RenderFlex

你好,我是新来的颤振。我正在做一些颤动的项目,但我对这个小部件有一些问题,当我添加一个 FlatButton 时,我得到了 18 个像素的右溢出。你能帮助我吗?

我的代码:

Widget _drawFooter() {
        return Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              // mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                FlatButton(
                  onPressed: () {},
                  child: Text(
                    '10 COMMENTS',
                    style: _hashTagStyle,
                  ),
                ),
                Row(
                  children: [
                    IconButton(
                      icon: Icon(Icons.favorite),
                      onPressed: () {},
                      color: Colors.grey.shade400,
                    ),
                    Text('Open'),
                  ],
                ),
              ],
            ),
            Expanded(
              child: Row(
                // mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  FlatButton(
                    onPressed: () {},
                    child: Text(
                      'SHARE',
                      style: _hashTagStyle,
                    ),
                  ),
                  FlatButton(
                    onPressed: () {},
                    child: Text(
                      'OPEN',
                      style: _hashTagStyle,
                    ),
                  ),
                  /* FlatButton(
                    onPressed: () {},
                    child: Text(
                      'Open',
                      style: _hashTagStyle,
                    ),
                  ),*/
                  //  Text('Open'),
                ],
              ),
            ),
          ],
        );
      }
    }

这是屏幕截图错误:

在此处输入图像描述

标签: flutterdart

解决方案


您可以使用 wrap 而不是 row。这是代码:

        wrap(
      children: [
        FlatButton(
            onPressed: () {},
            child: Text(
                '10 COMMENTS',
                style: _hashTagStyle,
              ),
            ),
            Row(
              children: [
                IconButton(
                  icon: Icon(Icons.favorite),
                  onPressed: () {},
                  color: Colors.grey.shade400,
                ),
                Text('Open'),
              ],
            ),
            FlatButton(
                onPressed: () {},
                child: Text(
                  'SHARE',
                  style: _hashTagStyle,
                ),
              ),
            FlatButton(
                onPressed: () {},
                child: Text(
                    'OPEN',
                    style: _hashTagStyle,
                ),
            ),
          ],
        ),
        
      ],
    )

这对我有用。欲了解更多详情,请访问此网站


推荐阅读