getNotifications method

Future<void> getNotifications()

Implementation

Future<void> getNotifications() async {
  Map<String, dynamic> params = <String, dynamic>{};
  params['userId'] =
      GetIt.I<StorageUtils>().getUserId() ?? AppUrls.defaultUserId;
  params['userRoleTOList'] =
      '[{"IdUserRole":1,"UserId":1,"RoleId":1,"IsActive":1,"CreatedBy":1,"CreatedOn":"2017-01-01T00:00:00","RoleDesc":"SysAdmin","EnableAreaAlloc":0,"RoleTypeId":1}]';

  try {
    final response = await _apiService.getData(AppUrls.getAllActiveAlertList,
        queryParams: params);
    if (response.statusCode == 200) {
      final List<dynamic> jsonData = response.data['data'];
      final modelResponse =
          NotificationsResponse.fromDecodedJsonList(jsonData);
      notificationList.value = modelResponse;
      notificationCount.value = notificationList.length;
    } else {
      notificationCount.value = 0;
      print('Failed to load ');
    }
  } catch (e) {
    print('Failed to fetch data');
  }
}