From 369ea6cf5b3e1997567ba93e5ac9bd02bc86daa8 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 23 Nov 2025 12:46:49 +0800 Subject: [PATCH] :bug: Fix unmounted setState --- lib/widgets/content/embed/link.dart | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/widgets/content/embed/link.dart b/lib/widgets/content/embed/link.dart index 4e40179a..1f07fbfb 100644 --- a/lib/widgets/content/embed/link.dart +++ b/lib/widgets/content/embed/link.dart @@ -55,14 +55,18 @@ class _EmbedLinkWidgetState extends State { stream.removeListener(listener); final aspectRatio = info.image.width / info.image.height; - setState(() { - _isSquare = aspectRatio >= 0.9 && aspectRatio <= 1.1; - }); + if (mounted) { + setState(() { + _isSquare = aspectRatio >= 0.9 && aspectRatio <= 1.1; + }); + } } catch (e) { // If error, assume not square - setState(() { - _isSquare = false; - }); + if (mounted) { + setState(() { + _isSquare = false; + }); + } } }