asset_wizard: ^0.2.0, run dart pub get, and use the new short command dart run ak. These docs cover the original assetkamkaro package as published on pub.dev.low, medium, or high compression level per run.--delete-unused, plus per-file size reduction reporting.config.yaml configuration files, automatic backups, dry-run mode, and comprehensive error handling.OptimizationResult with totalSizeReduction, totalAssetsProcessed, the unusedAssets list, and a per-file compressionResults map. Because it supports dry runs and backups, you can preview and safely revert every change.args, crypto, flutter, image, path, and yaml.pubspec.yaml:12dependencies: assetkamkaro: ^0.1.1
1flutter pub get
1dart run assetkamkaro optimize --dry-run
AssetKamKaro instance and call optimize() with your project path and a compression level:12345678910111213import 'package:assetkamkaro/assetkamkaro.dart'; void main() async { final optimizer = AssetKamKaro(); final result = await optimizer.optimize( projectPath: 'path/to/your/flutter/project', compressionLevel: CompressionLevel.medium, ); print('Optimization complete!'); print('Total size reduction: ${result.totalSizeReduction}'); print('Unused assets found: ${result.unusedAssets.length}'); }
CompressionLevel is an enum with low, medium, and high options.OptimizationResult carries everything you need to report on the run:totalSizeReduction — bytes saved across the runtotalAssetsProcessed — how many assets were handledunusedAssets — assets never referenced in your projectcompressionResults — a per-file map with original size, compressed size, and reduction percentagedart run assetkamkaro optimize --compression high. See the full flag list in the Command line interface section below.--delete-unused removes files it considers unreferenced. Keep backup: true (the default shown throughout these docs) and review the unusedAssets list from a dry run before enabling it.config.yaml in your project root to make runs repeatable instead of re-passing flags:1234567891011121314151617181920212223# AssetKamKaro Configuration compression: level: high # Options: low, medium, high jpeg: quality: 80 # 0-100 subsampling: yuv420 png: level: 9 # 0-9 filter: 0 # Directories to exclude from optimization exclude: - assets/icons - assets/backgrounds - assets/raw # Backup settings backup: true delete_unused: false # Performance settings enable_cache: true parallel_processing: true
compression block sets a global level plus per-format knobs — JPEG quality (0–100) and subsampling, PNG compression level (0–9) and filter. exclude keeps directories like icons or raw originals untouched, while enable_cache and parallel_processing control performance.1234567891011121314151617# Basic optimization dart run assetkamkaro optimize # High compression with specific settings dart run assetkamkaro optimize \ --compression high \ --exclude assets/icons,assets/backgrounds \ --backup true # Dry run for analysis dart run assetkamkaro optimize --dry-run # Delete unused assets dart run assetkamkaro optimize --delete-unused # Custom configuration file dart run assetkamkaro optimize --config custom_config.yaml
--dry-run first on any project you haven't optimized before — it reports what would change, including the unused-asset list, without writing anything.optimize() parameters, and the OptimizationResult gives you full per-file detail:12345678910111213141516171819202122232425262728293031323334353637383940414243import 'package:assetkamkaro/assetkamkaro.dart'; void optimizeAssets() async { // Initialize the optimizer final optimizer = AssetKamKaro( enableCache: true, ); try { // Run optimization final result = await optimizer.optimize( projectPath: Directory.current.path, compressionLevel: CompressionLevel.high, dryRun: false, createBackup: true, excludePatterns: ['assets/icons', 'assets/raw'], ); // Process results print('Optimization Results:'); print('- Total assets processed: ${result.totalAssetsProcessed}'); print('- Total size reduction: ${(result.totalSizeReduction / 1024).toStringAsFixed(2)} KB'); // Handle unused assets if (result.unusedAssets.isNotEmpty) { print('\nUnused Assets Found:'); for (final asset in result.unusedAssets) { print('- $asset'); } } // Detailed compression results print('\nCompression Details:'); result.compressionResults.forEach((path, details) { print('$path:'); print(' - Original: ${(details.originalSize / 1024).toStringAsFixed(2)} KB'); print(' - Compressed: ${(details.compressedSize / 1024).toStringAsFixed(2)} KB'); print(' - Reduction: ${details.reduction.toStringAsFixed(2)}%'); }); } catch (e) { print('Optimization failed: $e'); } }
includePatterns restricts a run to matching globs, and compressionSettings applies different settings per asset type:12345678910111213141516171819void processSpecificAssets() async { final optimizer = AssetKamKaro(); // Process only images in specific directories await optimizer.optimize( projectPath: Directory.current.path, includePatterns: ['assets/images/**/*.png', 'assets/images/**/*.jpg'], compressionLevel: CompressionLevel.medium, ); // Process with different settings for different types await optimizer.optimize( projectPath: Directory.current.path, compressionSettings: { 'png': CompressionSettings(level: 9), 'jpg': CompressionSettings(quality: 85), }, ); }
12345678await optimizer.optimize( projectPath: Directory.current.path, compressionSettings: { 'icons': CompressionSettings(level: 9), // Maximum compression for icons 'backgrounds': CompressionSettings(quality: 85), // High quality for backgrounds 'content': CompressionSettings(quality: 80), // Balanced for content }, );
assets/images/icons, assets/images/backgrounds, assets/images/content, and an untouched assets/raw/ for original, unoptimized files makes this per-type strategy trivial to express — raw simply goes in exclude.123456789101112131415161718192021222324252627void preReleaseOptimization() async { final optimizer = AssetKamKaro(); // 1. Analyze current state final analysis = await optimizer.analyzeAssets( projectPath: Directory.current.path, ); // 2. Create backup await optimizer.createBackup( projectPath: Directory.current.path, backupPath: 'backups/pre_release_${DateTime.now().toIso8601String()}', ); // 3. Optimize assets final result = await optimizer.optimize( projectPath: Directory.current.path, compressionLevel: CompressionLevel.high, createBackup: true, ); // 4. Generate report await optimizer.generateReport( result: result, outputPath: 'reports/optimization_report.html', ); }
123456if (analysis.unusedAssets.isNotEmpty) { await optimizer.deleteUnusedAssets( assets: analysis.unusedAssets, backup: true, ); }
123456789101112131415161718192021222324252627282930name: Asset Optimization on: push: branches: [ main ] jobs: optimize: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup Flutter uses: subosito/flutter-action@v1 with: flutter-version: '3.x' - name: Install Dependencies run: flutter pub get - name: Optimize Assets run: dart run assetkamkaro optimize --compression high --backup true - name: Commit Changes run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add . git commit -m "Optimize assets" git push
123456789101112try { await optimizer.optimize(...); } catch (e) { // Check file permissions if (e is FileSystemException) { print('Permission error: ${e.message}'); } // Check disk space if (e is IOException) { print('Disk space error: ${e.message}'); } }
1234final result = await optimizer.optimize( compressionLevel: CompressionLevel.high, verifyResults: true, // Enable detailed verification );
12345await optimizer.optimize( batchSize: 25, // Reduce batch size parallelProcessing: false, // Disable parallel processing cacheEnabled: true, // Enable caching );
OptimizationResult after every run — compression is lossy at higher levels, and --delete-unused removes files.1234567891011121314151617181920212223242526272829303132333435363738# assetkamkaro — agent integration instructions Optimize this Flutter app's assets (compress images, find unused assets) using assetkamkaro ^0.1.1 (pub.dev). Follow these rules exactly: 1. Note the successor first: asset_wizard ^0.2.0 replaces assetkamkaro — migrating is a dependency rename plus `dart pub get`, and the CLI becomes `dart run ak`. Use asset_wizard for new projects if available; the instructions below are for the original assetkamkaro package. 2. Add to pubspec.yaml: assetkamkaro: ^0.1.1, then run flutter pub get. 3. ALWAYS start with a dry run before writing anything: dart run assetkamkaro optimize --dry-run Review the reported changes and the unusedAssets list. 4. Run the real optimization via CLI: dart run assetkamkaro optimize --compression high \ --exclude assets/icons,assets/backgrounds --backup true Other flags: --delete-unused (destructive — removes unreferenced files), --config custom_config.yaml. 5. Or drive it from Dart: create AssetKamKaro() and call optimize(projectPath: ..., compressionLevel: CompressionLevel.low | medium | high, dryRun:, createBackup:, excludePatterns:, includePatterns:, compressionSettings:). 6. Read the returned OptimizationResult: totalSizeReduction (bytes), totalAssetsProcessed, unusedAssets (list), compressionResults (per-file map of original size, compressed size, reduction %). Report these numbers to the user. 7. Supported formats: JPEG, PNG, WebP. For repeatable runs write a config.yaml at the project root (compression.level, jpeg.quality 0-100, png.level 0-9, exclude:, backup:, delete_unused:, enable_cache:, parallel_processing:). 8. Keep backups on (backup: true / createBackup: true) and never pass --delete-unused without first reviewing the dry-run unusedAssets list. Higher compression levels are lossy. 9. Pipeline APIs also available on the optimizer: analyzeAssets(), createBackup(projectPath:, backupPath:), generateReport(result:, outputPath:), deleteUnusedAssets(assets:, backup: true). Docs: https://docs.aliarain.com/assetkamkaro
llms.txt index.