浏览代码

fix: null check operator used on a null value

ashilkn 1 年之前
父节点
当前提交
bde6483144
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      lib/ui/components/buttons/button_widget.dart

+ 8 - 6
lib/ui/components/buttons/button_widget.dart

@@ -492,12 +492,14 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
     required ButtonAction? buttonAction,
     Exception? exception,
   }) {
-    if (Navigator.of(context).canPop()) {
-      Navigator.of(context).pop(ButtonResult(widget.buttonAction, exception));
-    } else if (exception != null) {
-      //This is to show the execution was unsuccessful if the dialog is manually
-      //closed before the execution completes.
-      showGenericErrorDialog(context: context);
+    if (mounted) {
+      if (Navigator.of(context).canPop()) {
+        Navigator.of(context).pop(ButtonResult(widget.buttonAction, exception));
+      } else if (exception != null) {
+        //This is to show the execution was unsuccessful if the dialog is manually
+        //closed before the execution completes.
+        showGenericErrorDialog(context: context);
+      }
     }
   }