Skip to content

The package is currently in its initial release (version 1.0.0) and provides a foundation for Flutter developers to manage and optimize their app size effectively. It's designed to be easy to integrate into existing Flutter projects.

License

Notifications You must be signed in to change notification settings

saty-a/flutter_app_size_reducer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

51 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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

πŸ”— Links


Made with ❀️ for the Flutter community

About

The package is currently in its initial release (version 1.0.0) and provides a foundation for Flutter developers to manage and optimize their app size effectively. It's designed to be easy to integrate into existing Flutter projects.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published