'Change the Auto-Indent Lines setting when using Flutter in Android Studio
Problem
Auto-Indent Lines improperly shifts indent of Redirecting constructors.
The result of Auto-Indent is below.
Project.getInbox()
: this.update(
foo: 1,
bar: 2,
baz: 3);
The result I want is below.
Project.getInbox()
: this.update(
foo: 1,
bar: 2,
baz: 3);
Question
- How can I change the Auto-Indent Lines setting in Android Studio.
Development Environment
- Android Studio 3.1.4
Tried → Error
- Tried : I checked "Preferences" -> "Code Style" -> "Dart" -> "Tabs and Indents" and "Wrapping and Braces" →Error : There is no applicable place.
Best regards,
Solution 1:[1]
Dart (and therefore Flutter) uses its own code formatter dartfmt, so it's not possible to control indentation etc through the IDE. In this case, dartfmt will format the code differently depending on the optional trailing comma.
Without
Project.getInbox() : this.update(foo: 1, bar: 2, baz: 3);
With
Project.getInbox()
: this.update(
foo: 1,
bar: 2,
baz: 3,
);
Solution 2:[2]
If you are an Android Developer and cannot leave Android Studio, since it's your coding home, but can't let go of flutter either.
Use a different theme: Visual Studio 2019 Dark Theme (this auto adjusts indentation and makes code look exactly as of Visual Studio Code). To install theme - plugins -> search "Visual Studio 2019 Dark Theme"
OR
Use a different font: I prefer
Font : "Droid Sans Mono Slashed" or "Monospaced" (You can use any that works for spacing)
Font size: 18 , Line Height 1.4 // For 14 inch screens
Font size: 14 , Line Height 1.2 // For 15.6 inch screens or larger
OR
A combination of above looks beautiful.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Richard Heap |
| Solution 2 | Vaibhav Aggarwal |


