Manish Dhruw
Manish Dhruw

Reputation: 803

Configure tab size for Dart/Flutter in Android Studio Arctic Fox 2020.3.1

I was using tab(size 6) for indention for flutter code in android studio. After updating Android Studio to Arctic Fox 2020.3.1 code indention resets to 2 space tab. I cant find option to change it.

Is it possible to use tab indention of size 6 ?

I am also considering using VSCode.

Upvotes: 0

Views: 933

Answers (2)

Vaibhav Aggarwal
Vaibhav Aggarwal

Reputation: 61

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.

Changing tab size won't work through Default.xml in codestyles.

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

enter image description here

OR

A combination of above looks beautiful.

enter image description here

Upvotes: 0

andymeadows
andymeadows

Reputation: 1336

Know it's been a bit on this, but you can change the tab -- just know they REALLY REALLY don't want you to do it.

You don't mention the OS and I'm currently on Windows. On Windows, you edit the file located at %APPDATA%\Google\AndroidStudio2020.3\codestyles\Default.xml and add the following snippet just before the closing </closeScheme> tag:

  <codeStyleSettings language="Dart">
    <indentOptions>
      <option name="INDENT_SIZE" value="6" />
      <option name="TAB_SIZE" value="6" />
    </indentOptions>
  </codeStyleSettings>  

File location will vary for other operating systems. An answer to this question for an older version contains older locations on other operating systems: How to use 4-space wide tab character in Android Studio?.

Those locations were identified in the above post as:

  • macOS: ~/Library/Preferences/ CONFIGURATION_FOLDER.
  • Linux: ~/. CONFIGURATION_FOLDER.

Configuration folder is the AndroidStudio[xyz]/codestyles folder -- AndroidStudio2020.3

Upvotes: 1

Related Questions