Icare
Icare

Reputation: 1371

How to add space after and before curly braces?

I am doing Flutter development and when I save, the code get formatted. It is nice but some settings are not what I want. For example, I would like to add a space after and before curly brace for my constructor:

Before

Device({this.deviceType});

After

Device({ this.deviceType });

How can I adjust Dart formatting or VS Code to handle that?

Thanks

Upvotes: 0

Views: 448

Answers (2)

Ben Konyi
Ben Konyi

Reputation: 3219

You can't configure dartfmt, the Dart formatter, to do this as it's intended to make all Dart code look the same regardless of the author. See the FAQ of package:dart_style (the backend of dartfmt) for more information as to why the formatter isn't configurable.

Upvotes: 1

Abion47
Abion47

Reputation: 24691

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.

Upvotes: 0

Related Questions