Change the Auto-Indent Lines setting when using Fl

2019-07-04 04:05发布

问题:

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,

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