getMrz method

String getMrz()

Gets the value of the MRZ detected.

return Value of the MRZ detected. throws DocumentException An error has occurred during Document Library execution.

Implementation

String getMrz() {
  Pointer<Char> pMrz = nullptr;
  Pointer<Int> pMrzSize = calloc.allocate(1);
  pMrzSize[0] = -1;
  try {
    var err = documentSDK.id3DocumentMrzReadingResult_GetMrz(_pHandle.value, pMrz, pMrzSize);
    if (err == DocumentError.insufficientBuffer.value) {
      pMrz = calloc.allocate(pMrzSize.value);
      err = documentSDK.id3DocumentMrzReadingResult_GetMrz(_pHandle.value, pMrz, pMrzSize);
      if (err != DocumentError.success.value) {
        throw DocumentException(err);
      }
    }
    final vMrz = utf8.decode(Uint8List.fromList(pMrz.cast<Uint8>().asTypedList(pMrzSize.value)));
    return vMrz;
  } finally {
    calloc.free(pMrz);
    calloc.free(pMrzSize);
  }
}