fix(upload_image): 优化图片显示组件
This commit is contained in:
@@ -96,22 +96,21 @@ class CustomerImagesNetworking extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String? sizeParams = '';
|
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) {
|
if (height != null && width != null) {
|
||||||
tempHeight = height!.toInt() <= 300 ? 300 : height!.toInt();
|
final h = height!.toInt() <= 2048 ? 2048 : height!.toInt();
|
||||||
sizeParams = '?x-oss-process=image/resize,h_$tempHeight,w_$tempWidth';
|
final w = width!.toInt() <= 2048 ? 2048 : width!.toInt();
|
||||||
|
sizeParams = 'x-oss-process=image/resize,h_$h,w_$w';
|
||||||
|
} else if (width != null) {
|
||||||
|
final w = width!.toInt() <= 2048 ? 2048 : width!.toInt();
|
||||||
|
sizeParams = 'x-oss-process=image/resize,h_$w,w_$w';
|
||||||
|
} else if (height != null) {
|
||||||
|
final h = height!.toInt() <= 2048 ? 2048 : height!.toInt();
|
||||||
|
sizeParams = 'x-oss-process=image/resize,h_$h,w_$h';
|
||||||
}
|
}
|
||||||
|
final separator = imageUrl.contains('?') ? '&' : '?';
|
||||||
return CachedNetworkImage(
|
return CachedNetworkImage(
|
||||||
imageUrl: imageUrl + sizeParams,
|
imageUrl: imageUrl.isEmpty ? imageUrl : '$imageUrl$separator$sizeParams',
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
fit: fit,
|
fit: fit,
|
||||||
|
|||||||
Reference in New Issue
Block a user