简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM