chore: New performant fade in for images

pull/953/head
Krille 2 years ago
parent bac2dceae4
commit a518f8a019
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -156,10 +156,17 @@ class _MxcImageState extends State<MxcImage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final data = _imageData; final data = _imageData;
final hasData = data != null && data.isNotEmpty;
return data == null || data.isEmpty
? placeholder(context) return Stack(
: Image.memory( children: [
if (!hasData) placeholder(context),
AnimatedOpacity(
opacity: hasData ? 1 : 0,
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
child: hasData
? Image.memory(
data, data,
width: widget.width, width: widget.width,
height: widget.height, height: widget.height,
@ -171,6 +178,13 @@ class _MxcImageState extends State<MxcImage> {
WidgetsBinding.instance.addPostFrameCallback(_tryLoad); WidgetsBinding.instance.addPostFrameCallback(_tryLoad);
return placeholder(context); return placeholder(context);
}, },
)
: SizedBox(
width: widget.width,
height: widget.height,
),
),
],
); );
} }
} }

Loading…
Cancel
Save