为什么TabCode缩进在VSCode中不一致? (飞镖语言)

时间:2019-09-10 04:18:19

标签: dart visual-studio-code vscode-settings

我想问一下“格式文档”功能,为什么在VScode中使用“文档格式”功能时,列表变得不规则,就像我下面附加的代码一样。

我试图将“编辑器:标签大小”设置为2,但是当我使用“格式化文档”时,我的代码变得不规则。

@override
Widget build(BuildContext context) {
````return new Container(
````````child: new Column(
``````children: <Widget>[
````````new Row(
``````````children: <Widget>[
````````````//slideshow
````````````new Expanded(
````````````````child: new CarouselSlider(
``````````````height: 150.0,

我希望这样的代码:

@override
``Widget build(BuildContext context) {
````return new Container(
``````child: new Column(
````````children: <Widget>[
``````````new Row(
````````````children: <Widget>[
``````````````//slideshow
``````````````new Expanded(
````````````````child: new CarouselSlider(
````````````````height: 150.0,

1 个答案:

答案 0 :(得分:0)

格式是由dart_style/dartfmt完成的,其约定是使用4 spaces for continued lines的2位缩进。

对于Flutter代码,这通常不是最佳格式,因此可以使用尾部逗号来稍微更改格式,以更好地发挥作用:

https://flutter.dev/docs/development/tools/formatting#using-trailing-commas