chore: Better error handling for image rendering
This commit is contained in:
parent
9ea7d307c2
commit
221c3ef6bd
2 changed files with 61 additions and 16 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -151,10 +152,20 @@ class _MxcImageState extends State<MxcImage> {
|
|||
fit: widget.fit,
|
||||
filterQuality:
|
||||
widget.isThumbnail ? FilterQuality.low : FilterQuality.medium,
|
||||
errorBuilder: (context, __, ___) {
|
||||
_imageData = null;
|
||||
WidgetsBinding.instance.addPostFrameCallback(_tryLoad);
|
||||
return placeholder(context);
|
||||
errorBuilder: (context, e, s) {
|
||||
Logs().d('Unable to render mxc image', e, s);
|
||||
return SizedBox(
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: Icon(
|
||||
Icons.broken_image_outlined,
|
||||
size: min(widget.height ?? 64, 64),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: SizedBox(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue