标签: dartfmt

VSCode 为数组等的代码格式设置宽度

如果我的数组超过一定长度:

const List hts = [200, 195, 190, 185, 180, 175, 170, 165, 160, 155, 150, 145];
Run Code Online (Sandbox Code Playgroud)

VSCode 的格式如下:

const List hts = [
  200,
  195,
  190,
  185,
  180,
  175,
  170,
  165,
  160,
  155,
  150,
  145,
  140
];
Run Code Online (Sandbox Code Playgroud)

我宁愿它没有,因为它使一个短数组占据了一半的页面。我怎样才能改变这个?

我也得到了更奇怪的格式,这意味着如果我注释掉一行,它只会注释掉一半的行:

这个:

   Text('RESULTS', style: kMainText),
   Text('Additional', textAlign: TextAlign.center, style: kSmallText),
Run Code Online (Sandbox Code Playgroud)

格式如下:

   Text('RESULTS', style: kMainText),
   Text('Additional',
          textAlign: TextAlign.center, style: kSmallText),
Run Code Online (Sandbox Code Playgroud)

第二行是一行,但我必须将其注释为两行。似乎在某处有某种“长度”设置,我可以更改以避免这种情况。如何编辑所有这些行为?

format dart visual-studio-code dartfmt

5
推荐指数
1
解决办法
1309
查看次数

如何防止 dartfmt 在 getter 和 setter 之间留下空格

这就是我要的。

int _foo = 42;
int get foo => _foo;
Run Code Online (Sandbox Code Playgroud)

但是当我使用 dartfmt 格式化代码时,它会变成

int _foo = 42;

int get foo => _foo;
Run Code Online (Sandbox Code Playgroud)

我怎样才能防止这种行为?

dart flutter dartfmt

5
推荐指数
1
解决办法
291
查看次数

标签 统计

dart ×2

dartfmt ×2

flutter ×1

format ×1

visual-studio-code ×1