decompressStringAsync method
Decompresses the given base64-encoded compressed string asynchronously.
Returns the decompressed string.
For large strings (above _asyncThreshold
), this is done in a separate isolate
to avoid blocking the main thread.
Implementation
Future<String> decompressStringAsync(String compressedData) async {
try {
return await IsolateRunner.runWithThreshold<_DecompressionMessage,
String>(
function: _decompressInIsolate,
message: _DecompressionMessage(
compressedString: compressedData,
),
dataSize: compressedData.length,
asyncThreshold: _asyncThreshold,
);
} catch (e) {
_log.warning('Failed to decompress string asynchronously: $e');
// Return the original data if decompression fails
return compressedData;
}
}