|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import 'package:im_flutter_sdk/im_flutter_sdk.dart'; |
|
|
|
import 'package:retrofit/http.dart'; |
|
|
|
|
|
|
|
class ImageItem extends StatelessWidget { |
|
|
|
final EMImageMessageBody imageBody; |
|
|
|
@ -102,7 +103,6 @@ class ImageItem extends StatelessWidget { |
|
|
|
double maxHeight = 200.w; |
|
|
|
double width = maxWidth; |
|
|
|
double height = maxHeight; |
|
|
|
Get.log(imageBody.thumbnailLocalPath ?? ''); |
|
|
|
// 如果有图片尺寸信息,根据比例调整 |
|
|
|
if (imageBody.width != null && imageBody.width! > 0 && |
|
|
|
imageBody.height != null && imageBody.height! > 0) { |
|
|
|
@ -117,18 +117,13 @@ class ImageItem extends StatelessWidget { |
|
|
|
width = maxHeight * aspectRatio; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 尝试显示网络缩略图 |
|
|
|
if (imageBody.thumbnailRemotePath != null && imageBody.thumbnailRemotePath!.isNotEmpty) { |
|
|
|
return Image.network( |
|
|
|
imageBody.thumbnailRemotePath!, |
|
|
|
if (imageBody.localPath != null && imageBody.localPath!.isNotEmpty) { |
|
|
|
return Image.file( |
|
|
|
File(imageBody.localPath), |
|
|
|
width: width, |
|
|
|
height: height, |
|
|
|
fit: BoxFit.cover, |
|
|
|
loadingBuilder: (context, child, loadingProgress) { |
|
|
|
if (loadingProgress == null) return child; |
|
|
|
return _buildLoadingContainer(width, height); |
|
|
|
}, |
|
|
|
errorBuilder: (context, error, stackTrace) { |
|
|
|
return _buildErrorContainer(width, height); |
|
|
|
}, |
|
|
|
|