getSchedules method

dynamic getSchedules({
  1. String? fromDate,
  2. String? toDate,
  3. String? positionId,
})

Implementation

getSchedules({String? fromDate, String? toDate, String? positionId}) async {
  Helper.progressDialog(Get.context!, "");
  try {
    String requestTime = "";
    String responseTime = "";
    await ApiClient(
      baseUrl: ApiConstant.ffmBaseUrl,
      onFetchRequestTime: (time) {
        requestTime = time;
      },
      onFetchResponseTime: (time) {
        responseTime = time;
      },
      screenName: "droListingScreen",
    )
        .getPartnerIds(
            positionId: positionId ?? "", fromDate: fromDate, toDate: toDate)
        .then((value) {
      Helper.logEvent(
        "RESPONSE_EVENT",
        success: true,
        endPoint: Api.getPartnerIds,
        responseDate: responseTime,
        screenName: "droListingScreen",
        requestDate: requestTime,
      );
      dashboardScheduleList.clear();
      dashboardScheduleList = value.content ?? [];
      if (dashboardScheduleList.isNotEmpty) {
        List<String> partnerIds = [];
        dashboardScheduleList.forEach(
          (element) {
            if (element.partnerId != null && element.partnerId!.isNotEmpty) {
              partnerIds.add(element.partnerId!);
            }
          },
        );
        storage.write("PARTNER_IDs", jsonEncode(partnerIds));
        log("Partnerids -> ${jsonEncode(partnerIds)}");
      }
      Get.close(1);
    }).onError((error, stackTrace) {
      storage.write("PARTNER_IDs", "");
      Get.close(1);
      MainController mainController = Get.put(MainController());
      mainController.showErrorPopup();
    });
  } catch (err, stacktrace) {
    Get.back();
    print(stacktrace);
  }
}