From 6ea0b40c11398b4ac9f443936b7be44ecac7639a Mon Sep 17 00:00:00 2001 From: Edward Patel Date: Mon, 14 Feb 2022 23:49:51 +0100 Subject: [PATCH] Check mounted before setState --- lib/src/widget.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/widget.dart b/lib/src/widget.dart index ab56541..82b3882 100755 --- a/lib/src/widget.dart +++ b/lib/src/widget.dart @@ -46,7 +46,9 @@ class _CubeState extends State { void initState() { super.initState(); scene = Scene( - onUpdate: () => setState(() {}), + onUpdate: () { + if (mounted) setState(() {}); + }, onObjectCreated: widget.onObjectCreated, ); // prevent setState() or markNeedsBuild called during build