show error message on image error
This commit is contained in:
+19
-11
@@ -879,21 +879,29 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
Widget _buildImage(
|
Widget _buildImage(
|
||||||
Attachment attachment,
|
Attachment attachment,
|
||||||
) {
|
) {
|
||||||
|
final errorWidget = Container(
|
||||||
|
width: 200,
|
||||||
|
height: 140,
|
||||||
|
color: Color(0xffd0021B).withAlpha(26),
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
Icons.error_outline,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (attachment.thumbUrl == null &&
|
||||||
|
attachment.imageUrl == null &&
|
||||||
|
attachment.assetUrl == null) {
|
||||||
|
return errorWidget;
|
||||||
|
}
|
||||||
|
|
||||||
return CachedNetworkImage(
|
return CachedNetworkImage(
|
||||||
imageUrl:
|
imageUrl:
|
||||||
attachment.thumbUrl ?? attachment.imageUrl ?? attachment.assetUrl,
|
attachment.thumbUrl ?? attachment.imageUrl ?? attachment.assetUrl,
|
||||||
errorWidget: (context, url, error) {
|
errorWidget: (context, url, error) {
|
||||||
return Container(
|
return errorWidget;
|
||||||
width: 200,
|
|
||||||
height: 140,
|
|
||||||
color: Color(0xffd0021B).withAlpha(26),
|
|
||||||
child: Center(
|
|
||||||
child: Icon(
|
|
||||||
Icons.error_outline,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
);
|
);
|
||||||
|
|||||||
+3
-3
@@ -16,10 +16,10 @@ dependencies:
|
|||||||
url_launcher: ^5.4.2
|
url_launcher: ^5.4.2
|
||||||
video_player: ^0.10.8+1
|
video_player: ^0.10.8+1
|
||||||
chewie: ^0.9.10
|
chewie: ^0.9.10
|
||||||
file_picker: ^1.5.0
|
file_picker: ^1.5.1
|
||||||
image_picker: ^0.6.3+4
|
image_picker: ^0.6.4
|
||||||
keyboard_visibility: ^0.5.6
|
keyboard_visibility: ^0.5.6
|
||||||
stream_chat: ^0.1.19
|
stream_chat: ^0.1.21
|
||||||
visibility_detector: ^0.1.4
|
visibility_detector: ^0.1.4
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user