asset_wizard 0.2.1 copy "asset_wizard: ^0.2.1" to clipboard
asset_wizard: ^0.2.1 copied to clipboard

A magical Flutter CLI tool that compresses images, removes unused assets, generates type-safe classes, creates ZIP backups and shrinks your app size in seconds.

AssetWizard โœจ๐Ÿง™ #

pub package License: MIT

A magical Flutter CLI tool that compresses images, removes unused assets, generates type-safe classes, creates ZIP backups and shrinks your app size in seconds.

๐Ÿ”„ Migrating from AssetKamKaro? #

Just change the dependency name to asset_wizard: ^0.2.0 and run dart pub get.
Old command is gone โ€“ use the new short one: dart run ak


โœจ Features #

  • ๐ŸŽจ Smart Image Compression - Reduce file sizes while maintaining quality
  • ๐Ÿ—‘๏ธ Unused Asset Detection - Find assets that aren't referenced in code
  • ๐Ÿ“ฆ ZIP Backup System - Never lose your original assets
  • ๐ŸŽค Interactive Questionnaire - Guided setup for beginners
  • ๐ŸŽญ Beautiful CLI - Cute mode with emojis and colors
  • โšก Short Command - Just ak instead of long commands
  • ๐Ÿ‘€ Watch Mode - Auto-optimize when assets change
  • ๐Ÿ—๏ธ Type-Safe Assets - Generate Dart classes for asset paths
  • ๐Ÿ›ก๏ธ Safe Operations - Dry-run mode and automatic backups

๐Ÿš€ Quick Start #

Installation #

# Add to your pubspec.yaml
dependencies:
  asset_wizard: ^0.2.0

# Or install globally for CLI use
dart pub global activate asset_wizard

Basic Usage #

# Interactive mode (recommended for first-time users)
dart run ak -i

# Or use with options
dart run ak --compression high --generate-class

# See all options
dart run ak --help

๐Ÿ“– Usage #

Command Line Interface #

# Initialize configuration
dart run ak init

# Basic optimization
dart run ak

# With specific compression level
dart run ak --compression high

# Dry run to analyze without making changes
dart run ak --dry-run

# Delete unused assets
dart run ak --delete-unused

# Generate type-safe asset class
dart run ak --generate-class

# Watch mode for automatic optimization
dart run ak --watch

# Clean up backup files
dart run ak clean

# Check version
dart run ak version

Interactive Mode ๐ŸŽค #

The easiest way to use AssetWizard:

dart run ak -i

This will guide you through:

  • Compression level selection
  • Unused asset deletion
  • Asset class generation
  • WebP conversion (coming soon)

Programmatic Usage #

import 'package:asset_wizard/asset_wizard.dart';

void main() async {
  final wizard = AssetWizard();
  
  final result = await wizard.optimize(
    projectPath: 'path/to/your/flutter/project',
    compressionLevel: CompressionLevel.medium,
    generateClass: true,
  );
  
  print('Total size reduction: ${result.totalSizeReduction} bytes');
  print('Assets processed: ${result.totalAssetsProcessed}');
  print('Unused assets found: ${result.unusedAssets.length}');
}

๐ŸŽฏ Configuration #

Create a config.yaml file in your project root:

compression:
  level: medium
  jpeg:
    quality: 80
    subsampling: yuv420
  png:
    level: 9
    filter: 0

exclude:
  - assets/icons
  - assets/backgrounds

backup: true
delete_unused: false

Or generate it automatically:

dart run ak init

๐ŸŽจ Features in Detail #

Smart Compression #

  • Low: Minimal compression, highest quality (10% reduction)
  • Medium: Balanced compression and quality (30% reduction)
  • High: Maximum compression, lower quality (50% reduction)

ZIP Backups ๐Ÿ“ฆ #

  • Automatic timestamped backups before optimization
  • Stored in .asset_wizard_backup/ directory
  • Restore anytime if something goes wrong
  • Skip with --no-backup flag

Asset Class Generator ๐Ÿ—๏ธ #

Generates lib/app_assets.dart with type-safe constants:

// GENERATED CODE - DO NOT MODIFY BY HAND
class AppAssets {
  AppAssets._();

  static const String logo_png = 'assets/images/logo.png';
  static const String icon_home = 'assets/icons/home.svg';
}

// Use in your code
Image.asset(AppAssets.logo_png)

Watch Mode ๐Ÿ‘€ #

Monitor your assets directory and automatically optimize when files change:

dart run ak --watch

Perfect for development workflow!

Cute Mode ๐ŸŽจ #

Enabled by default! Enjoy:

  • Beautiful ASCII art logo
  • Emoji-enhanced messages
  • Colorful progress bars
  • Animated spinners

Disable for CI/CD:

dart run ak --no-cute

๐Ÿ“Š CLI Options #

Option Short Description Default
--compression -c Compression level (low/medium/high) medium
--dry-run -d Analyze without making changes false
--backup -b Create ZIP backup before optimization true
--exclude -e Directories to exclude []
--delete-unused -D Delete unused assets false
--generate-class Generate AppAssets class false
--watch -w Watch for changes false
--interactive -i Use interactive questionnaire false
--cute Enable cute mode with emojis true
--help -h Show help information -

๐ŸŽฏ Use Cases #

  • ๐Ÿ“ฑ Before App Store submission - Reduce bundle size to meet requirements
  • ๐Ÿ”„ During development - Keep assets optimized with watch mode
  • ๐Ÿงน Spring cleaning - Remove unused assets and clean up
  • ๐Ÿš€ CI/CD Integration - Automate asset optimization in build pipelines
  • ๐Ÿ“Š Asset auditing - Understand what's taking up space

๐Ÿค Contributing #

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.


๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments #

  • image package for image processing
  • path package for path handling
  • yaml package for configuration
  • args package for CLI support
  • mason_logger for beautiful CLI output
  • archive for ZIP compression

๐Ÿ“ž Support #

If you find a bug or have a feature request, please open an issue.


Made with โœจ and ๐Ÿง™ by the Flutter community

Happy Optimizing! โœจ

1
likes
130
points
--
downloads

Publisher

unverified uploader

A magical Flutter CLI tool that compresses images, removes unused assets, generates type-safe classes, creates ZIP backups and shrinks your app size in seconds.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#flutter #assets #optimization #compression #performance

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

archive, args, crypto, dart_style, flutter, image, mason_logger, path, watcher, yaml

More

Packages that depend on asset_wizard