Have you ever tried to update an old Flutter project to the latest APIs and lint rules and got a ton of warnings like in this example?
This is very common, especially when you update Flutter to a new version on your system.
For example, all the text styles have been renamed in Flutter 3.7 as part of the migration to Material 3:
Rather than fixing all these warnings by hand, you can just run a simple command and watch the magic happen:
dart fix --apply
This will fix most of the warnings for you.
But in some cases,
dart fix can't determine the correct fix with certainty, so you'll have to do this by hand. This is easy and mostly a case of using the quick fix shortcut in VSCode (
CMD+. on MacOS,
CTRL+. on Windows).
To better understand how
dart fix works and how to use it alongside the Flutter analyzer, watch this video:
Level up your Flutter app’s performance. Get full visibility into your Flutter app’s performance, including crashes, exceptions in Dart, network health, custom traces, and more. Solve your trickiest issues, optimize user journeys, and wow your end users - again and again.
One cool thing about VSCode is that we can use the command palette to fix all issues on the current file:
But you know what's even better?
Fix All on Save. 🚀
Just add "source.fixAll" to "editor.codeActionsOnSave" on your VSCode settings, and you're good to go!
You can grab my VSCode
settings.jsonfile from here. For all my other time-saving tips, read: VSCode Shortcuts, Extensions & Settings for Flutter Development
When it comes to addressing linter issues, Dart and VSCode offer great tooling that can save you a lot of time. 🚀
So make sure you make the most of it. 👍