callTransactionDetailsApi method

Future<void> callTransactionDetailsApi(
  1. String transactionId
)

Implementation

Future<void> callTransactionDetailsApi(String transactionId) async {
  BuildContext context = Get.context!;
  WidgetsBinding.instance.addPostFrameCallback((_) {
    Helper.progressDialog(context, "Please wait..");
  });
  dio
      .get(
    'https://run.mocky.io/v3/450efa55-fc1c-4888-9c64-a104b2f39ea4',
    data: {"filterTransferOrderId": transactionId},
    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;
      CollectStockHistoryDetailsModel model =
          CollectStockHistoryDetailsModel();
      model = CollectStockHistoryDetailsModel.fromJson(creditData);
      if (model.status == true) {
        transactionDetailsList = model.data!.content!;
        searchedDetailsList.value = transactionDetailsList;
      } 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());
  });
}