fix(utils): 修复图片尺寸参数拼接逻辑
- 调整图片尺寸参数根据传入的宽高动态生成 - 解决默认最小尺寸为300的逻辑问题,保证图片不会偏小 - 将错误图片组件从Container改为SizedBox,保持尺寸一致 - 修改padding计算方式,防止布局异常 - 确保图片加载URL正确拼接尺寸参数
This commit is contained in:
@@ -96,16 +96,29 @@ class CustomerImagesNetworking extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
String? sizeParams = '';
|
||||||
|
int tempHeight = 300;
|
||||||
|
int tempWidth = 300;
|
||||||
|
if (height != null) {
|
||||||
|
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempHeight';
|
||||||
|
}
|
||||||
|
if (width != null) {
|
||||||
|
tempWidth = width!.toInt() <= 300 ? 300 : width!.toInt();
|
||||||
|
sizeParams = '?x-oss-process=image/resize,h_$tempWidth,w_$tempWidth';
|
||||||
|
}
|
||||||
|
if (height != null && width != null) {
|
||||||
|
tempHeight = height!.toInt() <= 300 ? 300 : height!.toInt();
|
||||||
|
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempWidth';
|
||||||
|
}
|
||||||
return CachedNetworkImage(
|
return CachedNetworkImage(
|
||||||
imageUrl: imageUrl,
|
imageUrl: imageUrl + sizeParams,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
fit: fit,
|
fit: fit,
|
||||||
errorWidget: (_, object, s) {
|
errorWidget: (_, object, s) {
|
||||||
return Container(
|
return SizedBox(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
padding: EdgeInsets.all((width ?? 0) / 2),
|
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/images/noContainer.png',
|
'assets/images/noContainer.png',
|
||||||
|
|||||||
Reference in New Issue
Block a user