fix_flutter_deprecations 0.1.0 copy "fix_flutter_deprecations: ^0.1.0" to clipboard
fix_flutter_deprecations: ^0.1.0 copied to clipboard

A powerful and extensible Dart CLI tool that automatically fixes Flutter deprecations in your codebase

Fix Flutter Deprecations #

Fix Flutter Deprecations Logo

ci coverage style: very good analysis License: MIT

A powerful and extensible Dart command-line tool that automatically fixes Flutter deprecations in your codebase. As Flutter evolves, APIs get deprecated and replaced with new ones. This tool helps you migrate your codebase efficiently by automatically applying common deprecation fixes.

Fix Flutter Deprecations in action

Features โœจ #

  • Automatic Deprecation Fixes: Automatically updates deprecated Flutter APIs to their modern equivalents
  • Extensible Architecture: Easily add new deprecation rules as Flutter evolves
  • Safe Operation: Dry-run mode to preview changes before applying them
  • Selective Fixes: Apply specific deprecation fixes or all at once
  • Progress Tracking: Clear feedback on what's being changed
  • Backup Support: Optional backup creation before making changes

Currently Supported Deprecations #

Deprecated API Replacement Flutter Version
.withOpacity(value) .withValues(alpha: value) 3.27+
surfaceVariant surfaceContainerHighest Material 3
onSurfaceVariant onSurface Material 3

Installation ๐Ÿ“ฆ #

Global Installation #

dart pub global activate fix_flutter_deprecations

Local Development #

dart pub global activate --source=path .

Usage ๐Ÿš€ #

Fix all deprecations in your project #

fix_deprecations

Preview changes without applying them (dry run) #

fix_deprecations --dry-run

Apply specific deprecation fixes #

fix_deprecations --rules withOpacity,surfaceVariant

Fix a specific file or directory #

fix_deprecations lib/src/widgets/
fix_deprecations lib/main.dart

Create backups before fixing #

fix_deprecations --backup

List all available deprecation rules #

fix_deprecations list

Command Reference #

# Fix all deprecations in current directory
fix_deprecations fix

# Fix with specific options
fix_deprecations fix --dry-run --verbose
fix_deprecations fix --rules withOpacity --backup lib/

# List available deprecation rules
fix_deprecations list

# Show version
fix_deprecations --version

# Show help
fix_deprecations --help

Running Tests with coverage ๐Ÿงช #

To run all unit tests use the following command:

$ dart pub global activate coverage 1.2.0
$ dart test --coverage=coverage
$ dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info

To view the generated coverage report you can use lcov .

# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
$ open coverage/index.html

Adding New Deprecation Rules ๐Ÿ”ง #

The tool is designed to be easily extensible. To add a new deprecation rule:

  1. Create a new rule class in lib/src/rules/
  2. Implement the DeprecationRule interface
  3. Register the rule in the rule registry

Example:

class MyDeprecationRule extends DeprecationRule {
  @override
  String get name => 'myDeprecation';
  
  @override
  String get description => 'Fixes MyOldAPI to MyNewAPI';
  
  @override
  String apply(String content) {
    // Implementation here
  }
}

Architecture ๐Ÿ—๏ธ #

The project follows a clean, extensible architecture:

  • Commands: CLI commands for different operations (fix, list, etc.)
  • Rules: Individual deprecation fix implementations
  • Processors: File processing and transformation logic
  • Utils: Shared utilities for file operations, logging, etc.

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.

Adding a new deprecation fix: #

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/new-deprecation-fix)
  3. Add your deprecation rule with tests
  4. Ensure all tests pass and code follows Very Good Analysis standards
  5. Commit your changes (git commit -m 'Add new deprecation fix for XYZ')
  6. Push to the branch (git push origin feature/new-deprecation-fix)
  7. Open a Pull Request

Generated with ๐Ÿ’™ by Very Good CLI

1
likes
0
points
46
downloads

Documentation

Documentation

Publisher

unverified uploader

Weekly Downloads

A powerful and extensible Dart CLI tool that automatically fixes Flutter deprecations in your codebase

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

args, cli_completion, equatable, mason_logger, meta, path, pub_updater

More

Packages that depend on fix_flutter_deprecations