callSubmitAPI method

Future<void> callSubmitAPI(
  1. List<Map<String, dynamic>> request
)

Implementation

Future<void> callSubmitAPI(List<Map<String, dynamic>> request) async {
  BuildContext context = Get.context!;
  WidgetsBinding.instance.addPostFrameCallback((_) {
    Helper.progressDialog(context, "Please wait..");
  });
  dio
      .get(
    'https://run.mocky.io/v3/bf5e3f36-685a-4bc3-9ebd-9ec4d9d94389',
    data: {"fieldForceId": "123", " assetList": request},
    options: Options(
      headers: {
        'Authorization': 'Bearer Authorization',
        'Content-Type': 'application/x-www-form-urlencoded',
      },
    ),
  )
      .then((response) {
    Get.back();
    if (response.data != null) {
      CollectStockSubmitModel model = CollectStockSubmitModel();
      print(response.data);
      Map<String, dynamic> creditData = response.data;
      model = CollectStockSubmitModel.fromJson(creditData);
      if (model.status == true) {
        // Get.to(() => CollectStockSuccess(
        //       model: model.data!,
        //     ));
      } else {
        if (model.errors != null) {
          Helper.messageDialog(
              Get.context!,
              model.errors![0].errorCode ?? "Try again!!",
              model.errors![0].errorDescription ?? "Something went wrong");
        }
      }
    }
  }, onError: (error) {
    print(error.toString());
    Get.back();
    Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
  });
}