getLocalizedValue method

String getLocalizedValue(
  1. String? language
)

Retrieves the localized value based on the provided language code.

param language The language code for which the value should be localized (e.g., 'en' for English, 'fr' for French). return The localized value corresponding to the provided language code. throws BiosealException An error has occurred during Bioseal Library execution.

Implementation

String getLocalizedValue(String? language) {
  Pointer<Char>? pLanguage = language?.toNativeUtf8().cast<Char>();
  Pointer<Char> pValue = nullptr;
  Pointer<Int> pValueSize = calloc.allocate(1);
  pValueSize[0] = -1;
  try {
    var err = biosealSDK.id3BiosealField_GetLocalizedValue(_pHandle.value, pLanguage ?? nullptr, pValue, pValueSize);
    if (err == BiosealError.insufficientBuffer.value) {
      pValue = calloc.allocate(pValueSize.value);
      err = biosealSDK.id3BiosealField_GetLocalizedValue(_pHandle.value, pLanguage ?? nullptr, pValue, pValueSize);
      if (err != BiosealError.success.value) {
        throw BiosealException(err);
      }
    }
    final vValue = utf8.decode(Uint8List.fromList(pValue.cast<Uint8>().asTypedList(pValueSize.value)));
    return vValue;
  } finally {
    if (pLanguage != null) {
      calloc.free(pLanguage);
    }
    calloc.free(pValue);
    calloc.free(pValueSize);
  }
}