summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/view_model/badge_motive_view_model.dart36
1 files changed, 22 insertions, 14 deletions
diff --git a/lib/view_model/badge_motive_view_model.dart b/lib/view_model/badge_motive_view_model.dart
index 87060f8..28acf42 100644
--- a/lib/view_model/badge_motive_view_model.dart
+++ b/lib/view_model/badge_motive_view_model.dart
@@ -37,22 +37,28 @@ class BadgeMotiveViewModel extends ChangeNotifier {
_busy = true;
notifyListeners();
- _motives = await _motivSelect.getMotives();
- _busy = false;
- notifyListeners();
+ try {
+ _motives = await _motivSelect.getMotives();
+ } finally {
+ _busy = false;
+ notifyListeners();
+ }
}
Future<void> setMotive(BadgeMotive motive) async {
if (_busy) return;
-
_busy = true;
notifyListeners();
- logger.t(">Set motive to ${motive.id}");
- await _motivSelect.setCurrentMotive(motive);
- logger.t("<Set motive to ${motive.id}");
- _busy = false;
- currentMotive = motive;
- notifyListeners();
+
+ try {
+ logger.t(">Set motive to ${motive.id}");
+ await _motivSelect.setCurrentMotive(motive);
+ logger.t("<Set motive to ${motive.id}");
+ currentMotive = motive;
+ } finally {
+ _busy = false;
+ notifyListeners();
+ }
}
Future<void> getCurrentMotive() async {
@@ -60,9 +66,11 @@ class BadgeMotiveViewModel extends ChangeNotifier {
_busy = true;
notifyListeners();
- currentMotive = await _motivSelect.getCurrentMotive();
-
- _busy = false;
- notifyListeners();
+ try {
+ currentMotive = await _motivSelect.getCurrentMotive();
+ } finally {
+ _busy = false;
+ notifyListeners();
+ }
}
}