๐Ÿ“ฆ 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