Using the Dart analyzer
When editing Flutter code, it's important to check the code with the analyzer.
If your IDE supports doing this automatically (e.g. using Android Studio with the Flutter plugin), then that is the easiest solution.
Alternatively, you can use the flutter analyze --flutter-repo
tool on the console. When using the
console, you will want to manually run flutter update-packages
each time you update your tree, so
that the pubspec.yaml
files are processed to obtain all the dependencies for every package in the
repository. If you don't do this, you may get bogus error messages about core classes like Offset
from dart:ui
. This is because flutter analyze
does not automatically attempt to update dependencies,
since doing so can take a long time and is only necessary when the tree has been updated.
For a one-off, use flutter analyze --flutter-repo
.
For continuous analysis, use flutter analyze --flutter-repo --watch
.
If you omit the --flutter-repo
option you may end up in a confusing state because that will
assume you want to check a single package and the flutter repository has several packages.
You can use the --write
argument with --watch
to cause each update to write all the results to a file
in ASCII. This can be used e.g. with Emacs' compile
mode to quickly dump all the latest analysis results
into the compilation buffer so that they are recognized as error messages that Emacs can jump to.
- Home of the Wiki
- Roadmap
- API Reference (stable)
- API Reference (main)
- Glossary
- Contributor Guide
- Chat on Discord
- Design documents
- Code of Conduct
- Issue triage reports (latest)
- Our Values
- Tree hygiene
- Issue hygiene and Triage
- Style guide for Flutter repo
- Project teams
- Contributor access
- What should I work on?
- Popular issues
- Running and writing tests
- Release process
- Flutter Framework Gardener Rotation
- Rolling Dart
- Manual Engine Roll with Breaking Commits
- Updating Material Design Fonts & Icons
- Postmortems and Retrospectives
- Hotfix Documentation Best Practices
- In case of emergency
- Landing Changes With Autosubmit
- Setting up the Framework development environment
- The Framework architecture
- API Docs code block generation
- Running examples
- Using the Dart analyzer
- The flutter run variants
- Test coverage for package:flutter
- Writing a golden-file test for package:flutter
- Managing template image assets
- Setting up the Engine development environment
- Compiling the engine
- Debugging the engine
- Using Sanitizers with the Flutter Engine
- Testing the engine
- The Engine architecture
- Flutter's modes
- Crashes
- more...
- Setting up the Packages development environment
- Plugins and Packages repository structure
- Contributing to Plugins and Packages
- Understanding Packages tests
- Plugin Tests
- Releasing a Plugin or Package
- more...