【发布时间】:2021-07-12 09:39:34
【问题描述】:
当我将小部件添加到 Column 小部件时,包装在 Expanded 小部件中的容器变得更小。即使我尝试增加容器(或图像)的高度,它也不会改变。
我该如何解决这个问题?
这里是小部件功能
Widget _buildWomanProductContainer({
required double width,
required double height,
required String imagePath,
required String clothProductName,
required String clothType,
required String clothPrice,}) {
return Column(children: [
Expanded(
child: Container(
alignment: Alignment.center,
height: height,
width: width,
child: ClipRRect(
borderRadius: BorderRadius.circular(12.0),
child: Image.asset(
imagePath,
height: height,
width: width,
fit: BoxFit.cover,
color: Color.fromRGBO(0, 0, 0, 0.4),
colorBlendMode: BlendMode.darken,
),
),
),
),
const SizedBox(height: 8),
Text(clothProductName,
style: TextStyle(
color: Color.fromRGBO(58, 67, 59, 1),
fontFamily: 'Merriweather-Regular',
)),
Text(clothType,
style: TextStyle(
color: Color.fromRGBO(58, 67, 59, 0.5),
fontFamily: 'Merriweather-Regular',
fontSize: 12)),
OutlinedButton(child: Text("Button"), onPressed: () {})
]);}
【问题讨论】:
-
但是图像是固定大小的
-
设置图片大小。用 Expanded 包裹您的列。
-
它不起作用