getNotifications method

Future<bool> getNotifications({
  1. bool showLoading = true,
})

Implementation

Future<bool> getNotifications({bool showLoading = true}) async {
  try {
      var response = await Requests.getDio(showLoadingDialog: showLoading).get("notifications?page=1");
      if (response.statusCode == 200) {
          NotificationsModel notificationsModel =
          NotificationsModel.fromJson(response.data);
          notificationsList.value = notificationsModel;
          notificationsList.refresh();
          unReadNotifications();
        return true;
      } else {
        CustomFlashWidget.showFlashMessage(
          type: FlashType.error,
          title: "Error",
          message: response.data?["errorCode"] ??
              response.data?["message"]?["errorCode"] ??
              "Something unexpected happened. Please try again later!",
        );
        return false;
      }
  } catch (e) {
     log("Error $e");
    return false;
    }
}