decompressString method

String decompressString(
  1. String compressedData
)

Decompresses the given base64-encoded compressed string.

Returns the decompressed string.

Implementation

String decompressString(String compressedData) {
  try {
    // Convert the base64-encoded string to bytes
    final compressedBytes = base64Decode(compressedData);

    // Decompress the bytes
    final decompressedBytes = _decompressBytes(compressedBytes);

    // Convert the decompressed bytes to a string
    final decompressedString = utf8.decode(decompressedBytes);

    _log.fine(
        'Decompressed string from ${compressedData.length} to ${decompressedString.length} characters');

    return decompressedString;
  } catch (e) {
    _log.warning('Failed to decompress string: $e');
    // Return the original data if decompression fails
    return compressedData;
  }
}