ShrinkAsync class abstract

An asynchronous utility class for compressing different types of data without blocking the UI.

This class provides static methods to compress various data types using separate isolates via compute:

  • bytes: Compresses raw binary data using identity or ZLIB compression and selects the best result
  • json: Compresses JSON objects efficiently
  • text: Compresses strings using UTF-8 encoding and zlib
  • unique: Compresses lists of unique integers using specialized algorithms

Always returns the same output as Shrink.* but wrapped in a Future.

Example:

// Asynchronously compress a string
final compressedFuture = ShrinkAsync.text('Hello world!');
final compressedBytes = await compressedFuture;

// Asynchronously compress a JSON object
final jsonCompressedFuture = ShrinkAsync.json({'name': 'John', 'age': 30});
final jsonCompressedBytes = await jsonCompressedFuture;

Constructors

ShrinkAsync.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

bytes(Uint8List bytes) Future<Uint8List>
Asynchronously compresses a Uint8List using zlib compression or no compression (identity).
json(Map<String, dynamic> json) Future<Uint8List>
Asynchronously compresses a JSON object using efficient encoding.
text(String text) Future<Uint8List>
Asynchronously compresses a string using UTF-8 encoding and zlib compression.
unique(List<int> list) Future<Uint8List>
Asynchronously compresses a list of unique integers using the most efficient algorithm.
uniqueManual(UniqueManualArgs args) Future<Uint8List>
Asynchronously compresses a list of unique integers using a specified compression method.