🐛 Fix unmounted setState
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user