asset_wizard 0.2.1
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 โจ๐ง #
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.0and rundart 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
akinstead 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-backupflag
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! โจ