问题:
当我使用这个小部件时,我有一个溢出错误(下面的代码(,我如何解决这个问题?
您可以在下图中看到错误。
在此处输入图像描述
Container(
height: 150,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(20),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
)
)...
你可以在这里查看完整的。
尝试使用Flexible((包装小部件。点击此处阅读更多信息https://api.flutter.dev/flutter/widgets/Flexible-class.html
The child Container should have defined height, try giving it a given height, and the height must not be greater than the parent height. - Increase the height of the parent container and also give the child Container a height and width
。
Container(
height: 300,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(20),
),
child: Container(
height:'your height',
width:'your width',
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
)
)...
您的Row
小部件对于屏幕来说太大了。你应该改变你的布局或将你的代码包装在FittedBox
假发中,如下所示:
Container(
height: 150,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(20),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
),
child: FittedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[...],
),
),
),
)