当我将小部件添加到 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: () {})
]);}
答案 0 :(得分:0)
我最终解决了这个问题!
因此,我们在处理图像几何形状方面没有溢出问题或限制
提供更新的代码:
Widget _buildWomanProductContainer({
required double width,
required double height,
required String imagePath,
required String clothProductName,
required String clothType,
required String clothPrice,}) {
return Wrap(
alignment: WrapAlignment.center,
children: [
Container(
width: width,
height: height,
child: Image.asset(
imagePath,
width: width,
height: height,
fit: BoxFit.cover,
color: Color.fromRGBO(0, 0, 0, 0.4),
colorBlendMode: BlendMode.darken,
),
),
Column(children: [
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(clothPrice,
style: TextStyle(
color: Color.fromRGBO(58, 67, 59, 1),
fontFamily: 'SolomonSans-SemiBold')),
onPressed: () {},
style: OutlinedButton.styleFrom(
side: BorderSide(width: 1.0, color: Color.fromRGBO(58, 67, 59, 1)),
),
)
],)
],
);
}