callHistoryApi method
void
callHistoryApi()
Implementation
void callHistoryApi() async {
BuildContext context = Get.context!;
WidgetsBinding.instance.addPostFrameCallback((_) {
Helper.progressDialog(context, "Please wait..");
});
dio
.get(
'https://run.mocky.io/v3/d49188e0-1d57-4083-8161-ece4322b6d1b',
data: CollectStockHistoryRequest(
startDate: "05-03-2024",
endDate: "05-03-2024",
filterType: "SCAN_IN")
.toJson(),
options: Options(
headers: {
'Authorization': 'Bearer Authorization',
'Content-Type': 'application/x-www-form-urlencoded',
'XuserToken': 'user token'
},
),
)
.then((response) {
Get.back();
if (response.data != null) {
if (kDebugMode) {
print(response.data);
}
Map<String, dynamic> creditData = response.data;
CollectStockHistoryModel model = CollectStockHistoryModel();
model = CollectStockHistoryModel.fromJson(creditData);
if (model.status == true) {
transactionHistoryList = model.data!.content!;
searchedOrderList.value = transactionHistoryList;
} else {
if (model.errors != null) {
Helper.messageDialog(
Get.context!,
model.errors![0].errorCode ?? "Try again!!",
model.errors![0].errorDescription ?? "Something went wrong");
}
}
}
}, onError: (error) {
if (kDebugMode) {
print(error.toString());
}
Get.back();
Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
});
}