diff --git a/lib/core/viewmodels/grades_details_viewmodel.dart b/lib/core/viewmodels/grades_details_viewmodel.dart index 953190b1c..ad17c6b39 100644 --- a/lib/core/viewmodels/grades_details_viewmodel.dart +++ b/lib/core/viewmodels/grades_details_viewmodel.dart @@ -32,21 +32,15 @@ class GradesDetailsViewModel extends FutureViewModel { @override Future futureToRun() async { - setBusyForObject(course, true); - - // ignore: return_type_invalid_for_catch_error - await _courseRepository - .getCourseSummary(course) - // ignore: return_type_invalid_for_catch_error - .catchError(onError) - .then((value) { - course = value; - }).whenComplete(() { + try { + setBusyForObject(course, true); + course = await _courseRepository.getCourseSummary(course); + notifyListeners(); + } catch(e) { + onError(e); + } finally { setBusyForObject(course, false); - }); - - notifyListeners(); - + } return course; } @@ -66,16 +60,14 @@ class GradesDetailsViewModel extends FutureViewModel { Future refresh() async { try { setBusyForObject(course, true); - await _courseRepository.getCourseSummary(course).then((value) { - course = value; - }); + course = await _courseRepository.getCourseSummary(course); notifyListeners(); - setBusyForObject(course, false); return true; - } on Exception catch (error) { + } catch (error) { onError(error); - setBusyForObject(course, false); return false; + } finally { + setBusyForObject(course, false); } }