callDroDistributerListApi method

Future<void> callDroDistributerListApi(
  1. int pageNumber,
  2. String keyword,
  3. bool isScroll
)

Implementation

Future<void> callDroDistributerListApi(
    int pageNumber, String keyword, bool isScroll) async {
  BuildContext context = Get.context!;
  WidgetsBinding.instance.addPostFrameCallback((_) {
    Helper.progressDialog(context, "Please wait..");
  });
  await ApiClient(baseUrl: ApiConstant.baseUrl)
      .getDroDistributerList(
          status: 1,
          order: "asc",
          size: 10,
          page: pageNumber,
          userType: 2,
          softDelete: false,
          sort: "firstName",
          isSalesForce: true,
          listAll: true,
          partnerId: partnerId,
          keyword: keyword)
      .then((response) {
    Get.back();
    DroDustributerListModel model = response;
    if (pageNumber == 1) {
      droDistributerList.value = model.content ?? [];
      searchedDroDistributerList.value = droDistributerList.obs.value;
      Get.to(() => const DroDistributerListScreen());
    } else {
      droDistributerList.addAll(model.content ?? []);
      searchedDroDistributerList.value = droDistributerList.obs.value;
    }
    isLoadingMore.value = false;
    totalElements.value = model.totalElements ?? 0;
    // if (model.content != null && !isScroll) {
    //   droDistributerList.value = model.content ?? [];
    //   searchedDroDistributerList.value = droDistributerList;

    // } else {
    //   currentPage.value -= 1;
    // }
    // if (model.status == "POS200") {

    // } else {

    // }
  }, onError: (error) {
    print(error.toString());
    Get.back();
    Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
  });
}