填充( 填充:EdgeInsets.only( 左:屏幕宽度 * 0.05, 右:屏幕宽度 * 0.05, 顶部:屏幕高度 * 0.06, ), 子项:容器( 宽度:双无穷大, height:卡片高度, 装饰:BoxDecoration( 颜色:CustomColor.bordercolor, borderRadius: BorderRadius.circular(屏幕宽度 * 0.05), 边框:边框.all( 颜色:CustomColor.textfieldcolor, 宽度:屏幕宽度*0.005, ), ),
// child: Padding(
// padding: EdgeInsets.only(top: screenHeight * 0.16),
// child:
// ),
child: Flexible(
child: ListView(
// physics: NeverScrollableScrollPhysics(),
// shrinkWrap: true,
children: [
if (!isTrue)
for (int i = 0; i < widget.couponDetails.length; i++)
Padding(
padding: EdgeInsets.only(
left: screenWidth * 0.065,
),
child: Row(
children: [
Expanded(
child: Text(
widget.couponDetails[i],
style: StyeleConstants.normalblacktextstyle400,
),
),
],
),
),
],
),
),
),
),
我尝试了不同的方法,但仍然不起作用
答案很简短:不要施加尺寸限制。
默认情况下,容器和许多其他小部件会尝试足够大以适合其子部件,除非您已经预定义了尺寸约束。
Container( width: double.infinity, height: cardHeight)
Container( width: double.infinity,)
还有其他可行的建议,例如如果该容器位于
Flexible
内,则用 Column
包裹该容器。
这个想法围绕着不为该容器提供固定尺寸。
希望对您有帮助。