getCharacterMetadata method
Returns the character metadata as a FileContents object.
If saveToMemory is enabled and the metadata is already loaded, returns the cached version. Otherwise, reads from the file.
Throws an Exception if the utility is not initialized.
Implementation
Future<FileContents> getCharacterMetadata() async {
if (isInitialized) {
FileContents? metadataFromMemory = getMetadataFromMemory;
if (saveToMemory && metadataFromMemory != null) {
assert(_metadata != null);
return metadataFromMemory;
} else {
var result = await readFile(metadataPath!);
if (saveToMemory) {
_metadata = result;
}
return result;
}
} else {
throw Exception('Not Initialized');
}
}