I'm creating a Flutter app in android studio. Under Settings -> Editor -> Code Style -> Dart, I enabled "use tab character" and changed the tab size and indent to 4.
However, nothing seemed to have changed in the main.dart file, so I used Ctrl-Alt-Shift-L to reformat the code (even tried with "code cleanup" enabled), but it still uses two spaces to indent.
How do I make android studio use tab characters?
You can still change the tab indents by manually editing the configuration files of Android Studio.
Open the configuration folder for codestyles:
macOS
~/Library/Application Support/Google/AndroidStudioXXXX.X/codestyles
Windows
%AppData%\Google\AndroidStudioXXXX.X\codestyles
or%AppData%\Roaming\Google\AndroidStudioXXXX.X\codestyles
Linux
currently unknown sorry
Add a new section into the file your IDE is using. Mine is codestyles/Default.xml
.
Like this:
<code_scheme name="Default" version="173">
...
<codeStyleSettings language="Dart">
<option name="BRACE_STYLE" value="2" />
<option name="METHOD_BRACE_STYLE" value="2" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
...
</code_scheme>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With