πŸ“¦ SmartPub - Flutter Dependency Analyzer

The smart way to manage Flutter dependencies.

pub package License: BSD-3-Clause

A cross-platform Dart/Flutter developer tool that analyzes and cleans dependencies in your pubspec.yaml file. SmartPub runs on Windows, macOS, and Linux, identifying unused, misplaced, and duplicate dependencies to keep your Flutter projects clean and efficient.

✨ Features

  • πŸ” Smart Analysis - Scans your entire project to detect dependency usage patterns
  • 🧹 Auto-Fix - Automatically removes unused dependencies and fixes misplaced ones
  • 🀝 Interactive Mode - Prompts for confirmation before making changes
  • πŸ›‘οΈ Safety First - Creates backups before modifications with easy restore
  • πŸ“Š Duplicate Detection - Finds and resolves duplicate dependencies with version conflicts

🌐 Platform Support

SmartPub works with Flutter projects targeting any platform:

  • βœ… Android
  • βœ… iOS
  • βœ… Web
  • βœ… macOS
  • βœ… Windows
  • βœ… Linux

πŸš€ Installation

dart pub global activate smartpub

Local Installation

Add to your pubspec.yaml:

dev_dependencies:
  smartpub: ^1.0.0

Then run:

dart pub get

πŸ“– Usage

Basic Analysis

# Analyze dependencies without making changes
smartpub --analyse

# Or simply
smartpub

Auto-Fix Mode

# Automatically fix all issues
smartpub --apply

Interactive Mode

# Review and apply changes interactively
smartpub --interactive

Restore from Backup

# Restore previous version
smartpub --restore

Update SmartPub

# Update to the latest version
smartpub --update

CI-Friendly Mode

# Disable colors for CI pipelines
smartpub --analyse --no-color

πŸ“‹ Command Reference

Command Description
smartpub or --analyse Analyze dependencies without making changes
--interactive Review and apply changes interactively
--apply Automatically apply fixes
--restore Restore pubspec.yaml from backup
--update Update SmartPub to the latest version
--no-color Disable colored output
--help Show help information
--version Show version information

🎯 What SmartPub Detects

βœ… Used Dependencies

Dependencies that are properly used in your lib/ directory.

🧩 Misplaced Dependencies

Dependencies used only in test/, bin/, or tool/ that should be in dev_dependencies.

⚠️ Unused Dependencies

Dependencies declared but never imported in your code.

πŸ”„ Duplicate Dependencies

Packages declared in both dependencies and dev_dependencies with intelligent recommendations.

πŸ“Š Example Output

πŸ“¦ SmartPub - Flutter Dependency Analyzer

βœ… Used Dependencies
βœ… http - used in lib
βœ… flutter_bloc - used in lib

🧩 Move to dev_dependencies
🧩 mockito - used in test

⚠️ Unused Dependencies
⚠️ lottie - unused

Summary
Total dependencies scanned: 12
⚠️ 2 issue(s) found that can be fixed

πŸ›‘οΈ Safety Features

  • Automatic Backups - Creates pubspec.yaml.bak before any modifications
  • Easy Restore - Restore previous version with --restore command
  • Error Recovery - Automatically restores backup if operations fail

πŸ”§ CI/CD Integration

Use SmartPub in your CI pipeline across different platforms:

# GitHub Actions example (works on ubuntu, windows, macos)
- name: Check dependencies
  run: |
    dart pub global activate smartpub
    smartpub --analyse --no-color

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

πŸ“„ License

This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.

πŸ“ž Support


Made with ❀️ by Vatsal Jaganwala

Libraries

analyzer
SmartPub Dependency Analyzer
apply_service
Apply Service
backup_service
Safety Backup Service
cli_output
CLI Output Formatter
config
SmartPub Configuration
interactive_service
Interactive Service
models/dependency_info
Dependency Information Model
pubspec_manager
Pubspec Manager
update_checker
Update Checker Service