🐛 Fix unmounted setState

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

View File

@@ -55,16 +55,20 @@ 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;
if (mounted) {
setState(() { setState(() {
_isSquare = aspectRatio >= 0.9 && aspectRatio <= 1.1; _isSquare = aspectRatio >= 0.9 && aspectRatio <= 1.1;
}); });
}
} catch (e) { } catch (e) {
// If error, assume not square // If error, assume not square
if (mounted) {
setState(() { setState(() {
_isSquare = false; _isSquare = false;
}); });
} }
} }
}
Future<void> _launchUrl() async { Future<void> _launchUrl() async {
final uri = Uri.parse(widget.link.url); final uri = Uri.parse(widget.link.url);