From 12091d5c0281bba27f09a206d845bdebdfe18c3a Mon Sep 17 00:00:00 2001 From: wuxinglong Date: Fri, 6 Feb 2026 15:23:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(utils):=20=E4=BF=AE=E5=A4=8D=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=B0=BA=E5=AF=B8=E5=8F=82=E6=95=B0=E6=8B=BC=E6=8E=A5?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整图片尺寸参数根据传入的宽高动态生成 - 解决默认最小尺寸为300的逻辑问题,保证图片不会偏小 - 将错误图片组件从Container改为SizedBox,保持尺寸一致 - 修改padding计算方式,防止布局异常 - 确保图片加载URL正确拼接尺寸参数 --- lib/utils/customer.dart | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/utils/customer.dart b/lib/utils/customer.dart index 995c13c..0f85f99 100644 --- a/lib/utils/customer.dart +++ b/lib/utils/customer.dart @@ -96,16 +96,29 @@ class CustomerImagesNetworking extends StatelessWidget { @override 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( - imageUrl: imageUrl, + imageUrl: imageUrl + sizeParams, width: width, height: height, fit: fit, errorWidget: (_, object, s) { - return Container( + return SizedBox( width: width, height: height, - padding: EdgeInsets.all((width ?? 0) / 2), child: Center( child: Image.asset( 'assets/images/noContainer.png',