Flutter App Size Reducer ๐
A comprehensive Flutter development toolkit for app size optimization, dependency analysis, code cleanup, and developer productivity.
Version 2.0 brings major improvements with beautiful CLI, dependency analysis, and much more!
โจ Features
๐ Asset Analysis
- Find unused assets in your Flutter project
- Identify large assets that should be optimized
- Scan project files for asset references
- Detailed reports with file sizes
๐ฆ Dependency Analysis NEW in v2.0
- Detect unused dependencies in
pubspec.yaml - Show latest package versions from pub.dev
- Find orphaned dev dependencies
- Interactive cleanup suggestions
๐งน Smart Cleanup
- Safely remove unused assets
- Interactive selection mode
- Dry-run option to preview changes
- Backup support before deletion
๐จ Image Optimization
- Optimize PNG, JPG, JPEG, GIF, WebP images
- Configurable quality settings
- Batch processing
- Before/after size comparison
๐ฏ Beautiful CLI NEW in v2.0
- Colored output with progress indicators
- Interactive prompts and confirmations
- JSON output for CI/CD integration
- Command categories and better help
โ๏ธ Flexible Configuration
- Comprehensive YAML configuration
- Customizable thresholds and exclusions
- Per-feature settings
- Easy setup with interactive prompts
๐ Quick Start
Installation
Option 1: Global Activation (Recommended)
Activate the package globally for easy access from anywhere:
dart pub global activate flutter_app_size_reducer
After activation, you can use the short command:
fasr --help
Option 2: Add as Dev Dependency
Add to your pubspec.yaml:
dev_dependencies:
flutter_app_size_reducer: ^2.0.0
Then run:
flutter pub get
Usage
With Global Activation (Short Command)
# Initialize configuration
fasr init
# Analyze your project
fasr analyse
# Analyze only dependencies
fasr analyse --type=dependencies
# Clean unused assets
fasr clean --dry-run
# Optimize images
fasr optimize --quality=85
Without Global Activation (Dev Dependency)
dart run flutter_app_size_reducer init
dart run flutter_app_size_reducer analyse
# ... etc
๐ก Pro Tip: Use global activation for the best experience! Just type
fasrinstead of the long command.
๐ Commands
init - Initialize Configuration
fasr init [options]
Options:
--path=<path>- Custom configuration file path
analyse (or analyze) - Analyze Project
fasr analyse [options]
Options:
--type=<type>- Analysis type:assets,dependencies,all(default:all)--export=<path>- Export report to file
Examples:
# Analyze everything
fasr analyse
# Only analyze dependencies
fasr analyse --type=dependencies
# Export results
fasr analyse --export=report.json
clean - Clean Unused Assets
fasr clean [options]
Options:
--dry-run- Show what would be deleted without deleting--force- Skip confirmation prompt
optimize - Optimize Large Assets
fasr optimize [options]
Options:
--quality=<n>- JPEG quality (1-100, default: 85)--dry-run- Show what would be optimized without optimizing--force- Skip confirmation prompt
Global Options
All commands support:
--help,-h- Show help--version,-v- Show version--json- Output in JSON format (for CI/CD)--[no-]color- Enable/disable colored output--verbose- Enable verbose logging
โ๏ธ Configuration
The flutter_app_size_reducer.yaml file structure:
assets:
maxAssetSize: 1048576 # 1MB in bytes
excludeExtensions:
- ttf
- otf
- json
excludePaths:
- assets/fonts/
- assets/config/
optimizeImages: true
optimizeQuality: 85
imageFormats:
- png
- jpg
- jpeg
- gif
- webp
dependencies:
checkUnused: true
checkOutdated: true
excludePackages: []
suggestAlternatives: true
code:
detectUnusedCode: true
detectUnusedImports: true
analyzeDirs:
- lib
excludeDirs:
- lib/generated/
minComplexity: 10
build:
buildTypes:
- apk
trackHistory: true
maxHistoryEntries: 10
sizeBudget: 0 # 0 = no budget
reporting:
outputFormat: markdown # markdown, json, html, all
openHtmlReports: false
reportDir: .reports
includeCharts: true
useColors: true
๐ Programmatic Usage
You can also use the package programmatically in your Dart code:
import 'package:flutter_app_size_reducer/flutter_app_size_reducer.dart';
void main() async {
// Initialize configuration
await FlutterAppSizeReducer.init();
// Analyze project
final results = await FlutterAppSizeReducer.analyze();
print('Analysis complete!');
// Clean unused assets
await FlutterAppSizeReducer.clean(dryRun: true);
// Optimize images
await FlutterAppSizeReducer.optimize(quality: 80);
}
๐ What's New in v2.0
- ๐จ Beautiful CLI with colors, progress bars, and better UX
- ๐ฆ Dependency Analysis - detect unused packages
- โ๏ธ Enhanced Configuration - more options and better structure
- ๐ง Interactive Setup - guided configuration during init
- ๐ Better Reports - more detailed and exportable
- ๐ Improved Performance - faster scanning and analysis
See CHANGELOG.md for detailed changes.
๐ Migrating from v1.x
Version 2.0 includes breaking changes. To migrate:
- Backup your old config file
- Run
dart run flutter_app_size_reducer initto create a new config - Review and adjust settings as needed
The new config format provides much more control and new features!
๐ค Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support
If you find this package helpful, please:
- โญ Star the repository
- ๐ Report issues
- ๐ก Suggest new features
- ๐ค Contribute code
๐ Links
Made with โค๏ธ for the Flutter community
Libraries
- flutter_app_size_reducer
- A command-line tool to analyze and reduce Flutter app size by managing assets and dependencies.