Code formatting

Tools

Code formatting

Automatically formatting code in VS Code

Automatically formatting code in Android Studio and IntelliJ

Automatically formatting code with the dart command

Using trailing commas

While your code might follow any preferred style—in our
experience—teams of developers might find it more productive to:

Have a single, shared style, and

Enforce this style through automatic formatting.

The alternative is often tiring formatting debates during code reviews,
where time might be better spent on code behavior rather than code style.

Automatically formatting code in VS Code

Install the Flutter extension (see
Editor setup)
to get automatic formatting of code in VS Code.

To automatically format the code in the current source code window,
right-click in the code window and select Format Document.
You can add a keyboard shortcut to this VS Code Preferences.