fix_flutter_deprecations 0.1.1
fix_flutter_deprecations: ^0.1.1 copied to clipboard
A powerful and extensible Dart CLI tool that automatically fixes Flutter deprecations in your codebase
Fix Flutter Deprecations #
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.
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:
- Create a new rule class in
lib/src/rules/ - Implement the
DeprecationRuleinterface - 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: #
- Fork the repository
- Create your feature branch (
git checkout -b feature/new-deprecation-fix) - Add your deprecation rule with tests
- Ensure all tests pass and code follows Very Good Analysis standards
- Commit your changes (
git commit -m 'Add new deprecation fix for XYZ') - Push to the branch (
git push origin feature/new-deprecation-fix) - Open a Pull Request
Built with Claude Code by Moinsen Development ยฉ 2025
Bootstrapped with ๐ by Very Good CLI