From 05e95afef500ebd809a3b0e9f3004463e787d29a Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Fri, 8 Oct 2021 19:30:36 -0700 Subject: [PATCH] Fix issue #159 --- lib/src/widgets/rive_animation.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/widgets/rive_animation.dart b/lib/src/widgets/rive_animation.dart index e79095d..e6440e5 100644 --- a/lib/src/widgets/rive_animation.dart +++ b/lib/src/widgets/rive_animation.dart @@ -100,6 +100,12 @@ class _RiveAnimationState extends State { /// Initializes the artboard, animations, state machines and controllers void _init(RiveFile file) { + if (!mounted) { + /// _init is usually called asynchronously, so this is a good time to + /// check if the widget is still mounted. If it's not we can get out of + /// here early. + return; + } final artboard = (widget.artboard != null ? file.artboardByName(widget.artboard!) : file.mainArtboard)