๐ Code style
It's good to keep consistent code style, at least project-wide, and Dart/Flutter does come with linting support.
Lintingโ
We're using flutter_lints
package which contains recommended rules for Flutter apps.
Run linting by running flutter analyze
command in the root of the project or integrate linter with your IDE.
Formattingโ
To format the code use flutter format lib/
or flutter format test/
command in the root of a project.
Usage with VS Codeโ
Linting can be easily integrated via Flutter extension.
With this extension, you can find analysis issues in the Problems tab:
To see issues next to affected line use Error Lens extension.
Auto-formatting on file saveโ
Enable automatic code formatting on each file save by settings Manage (Bottom left cog icon) โก Settings
, then search for Editor: Format On Save and enable the checkbox: