我正在学习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),但这不会破坏每行一个参数。
尽可能添加彗差
,
将提供您想要的结果。对于您的情况,您可以在 ],
之后添加另一个昏迷。这将格式化代码。
CustomSwitch(),
],
),