getLocalizedLabel method
- String? language
Retrieves the localized label based on the provided language code.
param language The language code for which the label should be localized (e.g., 'en' for English, 'fr' for French). return The localized label corresponding to the provided language code. throws BiosealException An error has occurred during Bioseal Library execution.
Implementation
String getLocalizedLabel(String? language) {
Pointer<Char>? pLanguage = language?.toNativeUtf8().cast<Char>();
Pointer<Char> pLabel = nullptr;
Pointer<Int> pLabelSize = calloc.allocate(1);
pLabelSize[0] = -1;
try {
var err = biosealSDK.id3BiosealField_GetLocalizedLabel(_pHandle.value, pLanguage ?? nullptr, pLabel, pLabelSize);
if (err == BiosealError.insufficientBuffer.value) {
pLabel = calloc.allocate(pLabelSize.value);
err = biosealSDK.id3BiosealField_GetLocalizedLabel(_pHandle.value, pLanguage ?? nullptr, pLabel, pLabelSize);
if (err != BiosealError.success.value) {
throw BiosealException(err);
}
}
final vLabel = utf8.decode(Uint8List.fromList(pLabel.cast<Uint8>().asTypedList(pLabelSize.value)));
return vLabel;
} finally {
if (pLanguage != null) {
calloc.free(pLanguage);
}
calloc.free(pLabel);
calloc.free(pLabelSize);
}
}