Kaynağa Gözat

handled cases where toggle's onChanged returns an error

ashilkn 2 yıl önce
ebeveyn
işleme
64591cf02c
1 değiştirilmiş dosya ile 3 ekleme ve 1 silme
  1. 3 1
      lib/ui/components/toggle_switch_widget.dart

+ 3 - 1
lib/ui/components/toggle_switch_widget.dart

@@ -76,7 +76,9 @@ class _ToggleSwitchWidgetState extends State<ToggleSwitchWidget> {
                   );
                 });
                 final Stopwatch stopwatch = Stopwatch()..start();
-                await widget.onChanged.call();
+                await widget.onChanged.call().onError(
+                      (error, stackTrace) => _debouncer.cancelDebounce(),
+                    );
                 //for toggle feedback on short unsuccessful onChanged
                 await _feedbackOnUnsuccessfulToggle(stopwatch);
                 //debouncer gets canceled if onChanged takes less than debounce time