瀏覽代碼

Check if mounted before calling setState

ashilkn 2 年之前
父節點
當前提交
6c16c9dbbc
共有 1 個文件被更改,包括 5 次插入3 次删除
  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(() {
         executionState = ExecutionState.successful;
         Future.delayed(const Duration(seconds: 2), () {
-          setState(() {
-            executionState = ExecutionState.idle;
-          });
+          if (mounted) {
+            setState(() {
+              executionState = ExecutionState.idle;
+            });
+          }
         });
       });
     }