flutter_image_compress
2.5.1, released 4 months ago by fluttercandies.com
Compress pictures using native code to effectively reduce image size.
What it does
Compresses images using platform-native encoders on Android, iOS, macOS, Web, and OpenHarmony. Exposes methods for files, assets, and raw bytes, returning compressed bytes or files.
AI-written summary of version 2.5.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to reduce image file sizes before uploading them to a server.
- Dart-based image compression libraries are too slow for your application workloads.
Skip it when
- You are targeting platforms or formats not supported by the native encoders without fallback handling.
Strengths
- Dramatically faster than Dart-only image compression libraries.
- Supports multiple input types including files, asset images, and raw byte lists.
- Provides controls for quality, dimensions, rotation, and EXIF metadata preservation.
Weaknesses
- Certain features and formats (like WebP or HEIC) have platform-specific caveats or lack full support.
- Requires proper initialization when called from a background isolate.
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
Add the dependency to pubspec.yaml and import the package in your Dart code.
Future<Uint8List?> testCompressFile(File file) async {
final result = await FlutterImageCompress.compressWithFile(
file.absolute.path,
minWidth: 2300,
minHeight: 1500,
quality: 94,
rotate: 90,
);
return result;
}Alternatives
Packages that do the same job and could replace flutter_image_compress.
Works with
Packages commonly used together with flutter_image_compress: ones it builds on, ones built on it, and its own family.
- image_size_getterSame familyGet image width and height by reading metadata without fully decoding the file.
- image_editorSame familyEdit image data with native Android, iOS, and macOS code and output to file or memory.
- senior_design_systemBuilt on flutter_image_compressA Flutter UI kit providing Senior Design System components for mobile apps.
- image_compression_flutterBuilt on flutter_image_compressFlutter image compression and resizing for Mobile, Desktop, and Web.
- flutter_svg_imageBuilt on flutter_image_compressSVG ImageProvider for Flutter with caching support
- common_utils2Built on flutter_image_compressProduction-focused Flutter utilities for notifications, storage, connectivity, and media.