fetchUnreadReportsCnt method Null safety

Future<Map<String, int>?> fetchUnreadReportsCnt()

읽지않은 리포트 카드 갯수를 가져옵니다.

Implementation

Future<Map<String, int>?> fetchUnreadReportsCnt() async {
  LogManager().addLog("fetchUnreadReportsCnt", screen: runtimeType.toString());
  try {
    final dynamic body = await reqGET(
      path: '/api/reports/${farmState.currentFarm!.id}/count',
      queryParameters: {
        "cow_group_id": cowGroupState.currentCowGroup != null ? cowGroupState.currentCowGroup!.id.toString() : '',
      },
    );
    Map<String, int>? result = Map<String, int>.from(body);
    reportState.unreadReportsCnt = result;
    return result;
  } catch (e) {
    LogManager().addLog('fetchUnreadReportsCnt call failed: $e', screen: runtimeType.toString());
    return null;
  }
}