如何让 Dart 文件在 VsCode 中每个参数断行?

问题描述 投票:0回答:1

我正在学习Flutter/Dart,在我关注的视频系列中,每行只有一个参数,如下:

body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center, 
          children: [
            Text('Counter ${counter}'),
            CustomSwitch(),
          ]),
      )

但在我的编辑器中,该行不会按参数中断。

由于我使用的是 Dart 推荐设置,我认为在我的编辑器中它会是相同的,但发生的情况如下:

body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
          Text('Counter ${counter}'),
          CustomSwitch(),
        ]),

看看“child”属性如何在同一行中同时具有

mainAxisAliment
children
吗?

如何设置我的设置,以免发生这种情况,并且每行显示一个参数?

我以为我可以减少线宽(目前建议为 80),但这不会破坏每行一个参数。

flutter dart visual-studio-code ide editor
1个回答
0
投票

尽可能添加彗差

,
将提供您想要的结果。对于您的情况,您可以在
],
之后添加另一个昏迷。这将格式化代码。

 CustomSwitch(),
    ],
  ),
© www.soinside.com 2019 - 2024. All rights reserved.