fix_flutter_deprecations 0.2.0
fix_flutter_deprecations: ^0.2.0 copied to clipboard
A powerful and extensible Dart CLI tool that automatically fixes Flutter deprecations in your codebase
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased #
0.2.0 - 2026-05-04 #
Added #
- 10 new lint-fix rules that complement
dart fixforvery_good_analysis-style projects:cascadeInvocations: collapse runs ofobj.a(); obj.b(); obj.c();into a cascade chain. Skips capitalized receivers (static calls on classes) and any run that contains an assignment.controlBodyNewLine: rewrite inlineif (x) y;/for (...)/while (...)to a braced 3-line form, satisfying bothalways_put_control_body_on_new_lineandcurly_braces_in_flow_control_structures.avoidPrint: insert a documented// ignore: avoid_printabove any unguardedprint(...)call. Skips files with a file-level// ignore_for_file: avoid_printdirective and ignoresprintmentions inside string literals or comments.flutterStyleTodos: rewrite unnamed// TODO:(and/// TODO:) comments to the Flutter// TODO(unassigned):style.unintendedHtmlDocComment: wrap<Type>style fragments inside///doc comments in backticks. Allowed HTML tags (<br>,<p>,<a>,<code>, ...) are left alone.unreachableFromMain: heuristically tag test helpers (top-level functions and class members whose names containmock,setup,helper,seed,fixture,stub, orfake) with an indent-aware// ignore: unreachable_from_main.strictRawType: replaceMap<dynamic, dynamic>withMap<String, dynamic>, and bareMap/Listused as generic arguments (e.g.isA<Map>()→isA<Map<String, dynamic>>()).directivesOrdering: alphabetically sortimport/exportdirectives withindart:,package:, and relative groups. Multi-lineshow/asclauses are preserved.removedLint: remove retired lint names (e.g.package_api_docs,iterable_contains_unrelated_type, ...) fromanalysis_options.yaml.sortPubDependencies: alphabetically sortdependencies:,dev_dependencies:anddependency_overrides:blocks inpubspec.yamlwhile preserving comments and multi-line entries.
- YAML support: rules can now declare
appliesToExtensionsto target project-config files (pubspec.yaml,analysis_options.yaml) in addition to.dartsource files. The CLI scans config files at the project root automatically. - Generated-area exclusion:
.dart_tool/,build/,.fvm/directories are skipped during traversal. - File-level opt-out marker: a file containing
// fix_flutter_deprecations: ignore_filenear the top is left untouched. Useful for test fixtures that contain the very patterns rules look for. - Optional rule pool: rules with a higher false-positive risk live in
RuleRegistry.optionalRulesand only run when explicitly invoked via--rules. Currently containsOnSurfaceVariantRule(Material 3 keepsonSurfaceandonSurfaceVariantas distinct color slots, so a blind rename can produceduplicate_named_argumenterrors).
Fixed #
--help/-hnow prints usage instead of starting to process files.
Changed #
FileUtils.findDartFilesnow delegates toFileUtils.findProjectFiles, which accepts an extension set and aincludeProjectConfigsflag.FileProcessorfilters rules per-file based onappliesToExtensions, so yaml-only rules never run on Dart files and vice versa.
0.1.2 - 2025-08-03 #
Added #
- WillPopScope to PopScope Migration: Automatically converts deprecated
WillPopScopewidgets toPopScopewith intelligent callback transformation- Handles simple boolean returns by converting to
canPopproperty - Transforms complex logic into
onPopInvokedcallbacks with proper navigation handling
- Handles simple boolean returns by converting to
- Multiple Underscores Lint Fix: Automatically fixes "unnecessary use of multiple underscores" warnings
- Intelligently preserves generated code patterns and test mocks
- Converts multiple underscores to single underscores where appropriate
- BuildContext Async Safety: Fixes
use_build_context_synchronouslylint warnings by adding mounted checks- Automatically detects BuildContext usage after async operations
- Adds appropriate mounted checks (
if (mounted)for StatefulWidget,if (context.mounted)for others) - Supports Navigator, showDialog, ScaffoldMessenger, Theme, and MediaQuery operations
- Maintains proper code indentation and formatting
Enhanced #
- Extended rule registry to support 6 total deprecation rules
- Improved pattern matching with more sophisticated regex handling
- Enhanced validation logic for complex code transformations
0.1.1 - 2025-08-02 #
0.1.0 - 2025-08-02 #
Added #
- Initial release of fix_flutter_deprecations CLI tool
- Support for fixing
.withOpacity()to.withValues(alpha:)deprecation - Support for fixing
surfaceVarianttosurfaceContainerHighestdeprecation - Support for fixing
onSurfaceVarianttoonSurfacedeprecation - Dry-run mode to preview changes before applying
- Backup functionality for safe operation
- Selective rule application
- Progress tracking and detailed reporting
- Extensible architecture for adding new deprecation rules
- Comprehensive test coverage (100%)
- Full compatibility with Very Good Analysis standards
Features #
- Process single files or entire directories
- Parallel file processing for performance
- Detailed error reporting and recovery
- Platform support for Windows, macOS, and Linux