uploadFile method

void uploadFile(
  1. File xmlFile, {
  2. File? selfie,
})

Implementation

void uploadFile(File xmlFile, {File? selfie}) async {
  if (selfie != null) {
    selfieFile.value = selfie;
  }
  showLoader.value = true;
  var response = await _apiService.uploadXml(
    _aadhaarSdkController.clientId,
    _aadhaarSdkController.clientSecret,
    shareCodeController.text,
    xmlFile,
    selfie: selfie,
  );
  return response.fold((l) {
    showLoader.value = false;
    if (l.message.toLowerCase().contains("host")) {
      showToast(
        "No Internet Available",
        callback: () {
          _aadhaarSdkController.failureCallback(809);
          closeSdk();
        },
      );
    } else if (l.message.toLowerCase().contains("face")) {
      showToast(
        "Error: Face in selfie and face in UIDAI Aadhaar doesn’t match",
        callback: () {
          _aadhaarSdkController.failureCallback(810);
          closeSdk();
        },
      );
    } else {
      showToast(
        l.message,
        callback: () {
          _aadhaarSdkController.failureCallback(809);
          closeSdk();
        },
      );
    }
  }, (r) {
    responseData.value = r;
    showLoader.value = false;
    showSuccessOverlay.value = true;
    if (kDebugMode) {
      print(r);
    }
  });
}