🐛 Fix unmounted setState

This commit is contained in:
2025-11-23 12:46:49 +08:00
parent 2e371b5296
commit 369ea6cf5b

View File

@@ -55,14 +55,18 @@ class _EmbedLinkWidgetState extends State<EmbedLinkWidget> {
stream.removeListener(listener); stream.removeListener(listener);
final aspectRatio = info.image.width / info.image.height; final aspectRatio = info.image.width / info.image.height;
setState(() { if (mounted) {
_isSquare = aspectRatio >= 0.9 && aspectRatio <= 1.1; setState(() {
}); _isSquare = aspectRatio >= 0.9 && aspectRatio <= 1.1;
});
}
} catch (e) { } catch (e) {
// If error, assume not square // If error, assume not square
setState(() { if (mounted) {
_isSquare = false; setState(() {
}); _isSquare = false;
});
}
} }
} }