Browse Source

Check if mounted before calling setState

ashilkn 2 years ago
parent
commit
6c16c9dbbc
1 changed files with 5 additions and 3 deletions
  1. 5 3
      lib/ui/components/button_widget.dart

+ 5 - 3
lib/ui/components/button_widget.dart

@@ -334,9 +334,11 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
       setState(() {
       setState(() {
         executionState = ExecutionState.successful;
         executionState = ExecutionState.successful;
         Future.delayed(const Duration(seconds: 2), () {
         Future.delayed(const Duration(seconds: 2), () {
-          setState(() {
-            executionState = ExecutionState.idle;
-          });
+          if (mounted) {
+            setState(() {
+              executionState = ExecutionState.idle;
+            });
+          }
         });
         });
       });
       });
     }
     }