Explorar o código

Show error if execution fails after manually closing dialog

ashilkn %!s(int64=2) %!d(string=hai) anos
pai
achega
ea70d88eab
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      lib/ui/components/button_widget.dart

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

@@ -10,6 +10,7 @@ import 'package:photos/ui/common/loading_widget.dart';
 import 'package:photos/ui/components/models/button_type.dart';
 import 'package:photos/ui/components/models/custom_button_style.dart';
 import 'package:photos/utils/debouncer.dart';
+import "package:photos/utils/dialog_util.dart";
 
 enum ButtonSize {
   small,
@@ -489,11 +490,13 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
     required ButtonAction? buttonAction,
     Exception? exception,
   }) {
-    Navigator.of(context).canPop()
-        ? Navigator.of(context).pop(
-            ButtonResult(action: buttonAction, exception: exception),
-          )
-        : null;
+    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);
+    }
   }
 
   void _onTapDown(details) {