callTransactionAssetApi method
Implementation
Future<void> callTransactionAssetApi(
String transactionId, String productCode) async {
BuildContext context = Get.context!;
WidgetsBinding.instance.addPostFrameCallback((_) {
Helper.progressDialog(context, "Please wait..");
});
dio
.get(
'https://run.mocky.io/v3/ffdc2b64-e5f5-4da5-9c8c-48da53314d32',
data: {
"filterTransferOrderId": transactionId,
"productCode": productCode
},
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;
CollectStockHistoryAssetModel model = CollectStockHistoryAssetModel();
model = CollectStockHistoryAssetModel.fromJson(creditData);
if (model.status == true) {
transactionAssetList = model.data!.content![0].assetDetails!;
searchedAssetList.value = transactionAssetList;
} 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());
});
}