callDroDistributerListApi method
Implementation
Future<void> callDroDistributerListApi(
int pageNumber, String keyword, bool isScroll) async {
BuildContext context = Get.context!;
if (pageNumber == 1 && keyword.isEmpty) {
Helper.progressDialog(context, "Please wait..");
}
if (keyword.isNotEmpty) {
isSearching.value = true;
}
try {
await ApiClient(baseUrl: ApiConstant.baseUrl)
.getDroDistributerList(
status: 1,
order: "asc",
size: keyword.length > 2 ? 20 : 10,
page: pageNumber,
userType: 2,
softDelete: false,
sort: "firstName",
isSalesForce: true,
// listAll: true,
partnerId: partnerId,
keyword: keyword)
.then((response) {
DroDustributerListModel model = response;
if (pageNumber == 1) {
droDistributerList.value = model.content ?? [];
searchedDroDistributerList.value = droDistributerList.obs.value;
if (keyword.isEmpty) {
Get.back();
}
Get.to(() => const DroDistributerListScreen());
} else {
droDistributerList.addAll(model.content ?? []);
searchedDroDistributerList.value = droDistributerList.obs.value;
//Get.back();
}
isSearching.value = false;
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 {
// }
}).catchError((error) {
print(error.toString());
if (pageNumber == 1 && keyword.isEmpty) {
Get.back();
}
isSearching.value = false;
MainController mainController = Get.put(MainController());
mainController.showErrorPopup();
});
} catch (e) {
if (pageNumber == 1 && keyword.isEmpty) {
Get.back();
}
isSearching.value = false;
}
}