Chapter 1 · Practice 5 of 5
Turn on the recommended lints and treat analyzer warnings as work
From Dart and null safety
Why it matters
The analyzer is your cheapest reviewer. New Flutter projects include the flutter_lints package, and the Flutter performance docs specifically recommend it so you are reminded to use const where you can.
- Keep
analysis_options.yamlin the repo and includepackage:flutter_lints/flutter.yaml. - Run
flutter analyzein CI and fail the build on errors and warnings. - Add stricter rules your team agrees on, one at a time, and fix existing hits before turning each on.
An app with hundreds of ignored warnings hides the one warning that matters. Keep the count at zero so new problems stand out.
Do
- Run
flutter analyzein CI on every pull request - Fix or explicitly ignore each warning with a short reason
Avoid
- Deleting
analysis_options.yamlto make warnings go away
Example
# analysis_options.yaml
include: package:flutter_lints/flutter.yaml
linter:
rules:
prefer_const_constructors: true
avoid_print: true