fast_thumbhash 1.2.1
fast_thumbhash: ^1.2.1 copied to clipboard
Ultra-fast ThumbHash encoder/decoder for Dart and Flutter. A very compact representation of image placeholders with alpha support and natural loading transitions.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.2.1 - 2026-02-04 #
Added #
ThumbHash.fromBase64Async()- Create ThumbHash from base64 string with pre-decoded RGBA in isolate
1.2.0 - 2026-02-04 #
Added #
- Async methods - All CPU-intensive operations now have async versions that run in separate isolates, keeping the UI responsive:
thumbHashToRGBAAsync()- Decode ThumbHash asynchronouslyrgbaToThumbHashAsync()- Encode RGBA to ThumbHash asynchronouslythumbHashImageToPngAsync()- Encode PNG asynchronouslyThumbHash.toRGBAAsync()- Decode with caching, off main threadThumbHash.toPngBytesAsync()- Get PNG bytes, off main threadThumbHash.toImageAsync()- Get ImageProvider, off main thread
Changed #
- Minimum Dart SDK version updated to 2.19.0 (required for
Isolate.run())
1.1.1 - 2026-02-03 #
Fixed #
- Added validation to detect truncated or corrupted ThumbHash bytes before decoding, throwing a descriptive
ArgumentErrorinstead of crashing with index-out-of-bounds errors - Added
errorBuilderto internal placeholderImagewidget to gracefully handle decode failures by showing an empty widget
1.1.0 - 2026-02-03 #
Changed #
- BREAKING:
ThumbHashPlaceholder.errorWidgetis nowerrorBuilderwith signatureWidget Function(BuildContext context, Object error, StackTrace? stackTrace). This provides access to the error details and build context for better error handling.
Added #
ImageErrorWidgetBuildertypedef for the error builder function
1.0.0 - 2026-02-03 #
Added #
- Initial release of fast_thumbhash
- Ultra-fast ThumbHash decoder (7x faster than naive implementation)
- Fast PNG encoder with pre-allocated buffers (1.6x faster)
- Full ThumbHash API support:
thumbHashToRGBA()- Decode ThumbHash to RGBA imagergbaToThumbHash()- Encode RGBA image to ThumbHashthumbHashToAverageRGBA()- Extract average colorthumbHashToApproximateAspectRatio()- Get aspect ratio
- Flutter
ThumbHashconvenience class with:ThumbHash.fromBase64()- Create from base64 stringThumbHash.fromBytes()- Create from raw bytestoImage()- Get FlutterImageProvidertoAverageColor()- Get average color as FlutterColortoAspectRatio()- Get aspect ratio
- Natural image loading widgets:
ThumbHashPlaceholder- Simple widget with automatic transitionsThumbHashImageBuilder- Customizable builder for full controlTransitionConfig- Configure transition animations
- Transition effects:
- Fade - Simple crossfade
- Blur-to-sharp - Focus effect as image loads
- Scale-up - Subtle zoom effect
- None - Instant switch
- Full alpha channel support
- Comprehensive test suite (50+ tests)
- Performance benchmarks
Performance #
- Decode: ~12-17μs per image (7x faster than naive)
- PNG encode: ~13-20μs per image (1.6x faster than naive)
- Total pipeline: ~26-38μs per image
Optimizations #
- Separable 2D DCT/IDCT - ~5-7x fewer operations
- Pre-computed cosine tables
- Batched Adler-32 checksum (modulo every 5552 bytes)
- 256-entry CRC-32 table (single lookup per byte)