asset_shrink 0.1.0 copy "asset_shrink: ^0.1.0" to clipboard
asset_shrink: ^0.1.0 copied to clipboard

A zero-history, quality-gated Flutter and Dart dev-time asset compressor (PNG/JPEG) with native CLI and pure-Dart fallback.

example/example.md

asset_shrink Example #

This document demonstrates how to configure and use asset_shrink in your Flutter or Dart project.

1. Installation #

Add asset_shrink to your pubspec.yaml under dev_dependencies:

dev_dependencies:
  asset_shrink: ^0.1.0

2. Configuration (Optional) #

Configure compression settings in your pubspec.yaml:

asset_shrink:
  assets_dir: assets
  png_quality: "90-100"
  jpg_quality: 90
  exclude:
    - "assets/do_not_touch/**"
    - "assets/icons/no_shrink.png"

3. Usage #

Run the tool from your project root:

# Compress all assets in the configured assets directory
dart run asset_shrink

# Preview changes without modifying files
dart run asset_shrink --dry-run

# Compress a custom directory with specific quality settings
dart run asset_shrink custom/assets --quality 80-95 --jpg-quality 85 --verbose

4. Programmatic Usage in Dart #

import 'dart:io';
import 'package:asset_shrink/asset_shrink.dart';

void main() async {
  final config = await Config.loadFromPubspec(File('pubspec.yaml'));
  final runner = CliRunner(
    config: config,
    targetDir: 'assets',
    dryRun: false,
  );

  final report = await runner.run();
  print('Saved ${formatBytes(report.totalBytesSaved)} across ${report.compressedCount} files!');
}
2
likes
160
points
150
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A zero-history, quality-gated Flutter and Dart dev-time asset compressor (PNG/JPEG) with native CLI and pure-Dart fallback.

Repository (GitHub)
View/report issues

Topics

#assets #compression #flutter #cli #images

License

MIT (license)

Dependencies

args, glob, image, path, yaml

More

Packages that depend on asset_shrink