From 1d6a121ec4317aa7e5b757c4c3e57c691c553ff3 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Tue, 26 May 2026 09:47:23 -0400 Subject: [PATCH] calculate image aspect ratio for more accurate blurhash --- lib/widgets/renderers/event.dart | 42 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/lib/widgets/renderers/event.dart b/lib/widgets/renderers/event.dart index 611f7ee..217c4d3 100644 --- a/lib/widgets/renderers/event.dart +++ b/lib/widgets/renderers/event.dart @@ -316,19 +316,35 @@ class EventRenderer extends ConsumerWidget { ) => loadingProgress == null ? child : switch (info?.blurHash) { - final blurHash? => SizedBox( - width: - info?.width ?? - info?.height ?? - 200, - height: - info?.height ?? - info?.width ?? - 200, - child: BlurHash( - hash: blurHash, - ), - ), + final blurHash? => + info?.width == + null || + info?.height == + null + ? SizedBox( + width: + 200, + height: + 200, + child: BlurHash( + hash: + blurHash, + ), + ) + : AspectRatio( + aspectRatio: + info! + .width! / + info.height!, + child: SizedBox( + width: info + .width, + child: BlurHash( + hash: + blurHash, + ), + ), + ), _ => Loading(), }, errorBuilder: