dartformattingwebstorm

Change Dart Formatting style


Okay, so the title may be slightly misleading, This is simply my end goal.

So, I'm just getting into the world of Dart. So far it seems great, but my biggest issue with it is the stupid default formatter. In particular that you can't get rid of it. I'm using WebStorm mainly because of how customisable these things tend to be. But I haven't found any way to change the formatter for dart (see attached screenshot). The Dart formatter enforces 2-space indentations and many other infuriating code styles which are only enforced by it.

Is it possible to somehow change either the configuration options or the formatter all together? If the change has to be made to source, that's doable, or simply playing around with some WebStorm configurations, that's fine also, I just want to change this.

Thanks

As you can see, There is no way to configure anything other than the line length


Solution

  • The Dart formatter respects linter style rules as laid out in the "analysis_options.yaml" file. A description of the file can be found here. A complete list of linter rules can be found here.

    You can also subscribe to common style guides, such as pedantic, a package with the style guide used internally by Google, or lint, another package that enables all the rules that aren't either contradictory or opinionated.

    That being said, I don't think you can change things like the two-space indentation. There are certain style choices that dartfmt enforces in the interest of maintaining as much style consistency between Dart codebases as possible.