RyosukeOK
RyosukeOK

Reputation: 706

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

Development Environment

Tried → Error

Best regards,

Upvotes: 3

Views: 6851

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.

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

Richard Heap
Richard Heap

Reputation: 51682

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,
        );

Upvotes: 10

Related Questions