Flutter App Size Reducer ๐Ÿš€

pub package License: MIT CI codecov

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 fasr instead 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:

  1. Backup your old config file
  2. Run dart run flutter_app_size_reducer init to create a new config
  3. 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

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.