A Flutter package that helps reduce your app size by analyzing, cleaning, and optimizing assets.
- 🔍 Asset Analysis: Find unused and large assets in your Flutter project
- 🧹 Asset Cleaning: Remove unused assets to reduce app size
- 🚀 Asset Optimization: Optimize large assets to improve performance
- 📊 Detailed Reports: Get comprehensive reports about your assets
- 🔧 Configurable: Customize the behavior through a configuration file
- 🛠️ CLI Support: Use through command-line interface or programmatically
Add this to your package's pubspec.yaml
file:
dependencies:
flutter_app_size_reducer: ^<latest_version>
Then run: flutter pub get
Initialize the configuration:
dart run flutter_app_size_reducer init
Analyze your assets:
dart run flutter_app_size_reducer analyse
import 'package:flutter_app_size_reducer/flutter_app_size_reducer.dart';
void main() async {
// Initialize configuration
await FlutterAppSizeReducer.init();
// Analyze assets
final results = await FlutterAppSizeReducer.analyze();
print('Unused assets: ${results['unusedAssets']}');
print('Large assets: ${results['largeAssets']}');
// Clean unused assets
await FlutterAppSizeReducer.clean(dryRun: true);
// Optimize assets
await FlutterAppSizeReducer.optimize(quality: 80);
}
Create a flutter_app_size_reducer.yaml
file in your project root:
# Asset directories to analyze
asset_directories:
- assets/
- images/
# File extensions to consider as assets
asset_extensions:
- .png
- .jpg
- .jpeg
- .gif
- .webp
# Maximum size for assets (in bytes)
max_asset_size: 100000
# Quality for optimized images (0-100)
optimization_quality: 80
# Exclude patterns
exclude_patterns:
- "**/*.min.*"
- "**/generated/*"
Check out the example directory for a complete usage example.
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please open an issue.
- Initial release
- Added asset analysis functionality
- Added asset cleaning functionality
- Added asset optimization functionality
- Added configuration system
- Added CLI interface
- Added programmatic API
- Added example app
- Added comprehensive documentation
- Added test coverage
funding:
- type: github url: https://github.com/sponsors/saty-a
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at https://github.com/saty-a/flutter_app_size_reducer/issues. All complaints will be reviewed and investigated promptly and fairly.