flutter - Dart 格式在 vscode 中很奇怪
问题描述
我的飞镖文件的格式很奇怪
return Scaffold(
backgroundColor: bgColor,
body: SafeArea(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/$bgImage'), fit: BoxFit.cover)),
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 120, 0, 0),
child: Column(
children: <Widget>[
FlatButton.icon(
如何进行设置,以便正常的小部件树可以正确缩进。
另外,我设置了“editor.rulers”:[120],这仍然给了我不想要的自动缩进:
onPressed: () async {
**dynamic result =
await Navigator.pushNamed(context, '/location');**
setState(() {
data = {
'time': result['time'],
'location': result['location'],
'flag': result['flag'],
'isDaytime': result['isDaytime']
};
});
},
解决方案
在参数列表中使用尾随逗号。
没有尾随逗号:
Foo(arg1: ..., arg2: ...)
尾随逗号:
Foo(
arg1: ...,
arg2: ..., // notice the comma
)
例如:
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/$bgImage'),
fit: BoxFit.cover, // add a comma here
), // add a comma here
),
推荐阅读
- ssl - 如何为rabbitmq添加密码套件支持?
- javascript - 剩余 -100% 时检查 div 位置
- regex - Python3 正则表达式不适用于脚本,但适用于 pythex.org
- javascript - JS React:this.x is not a function 的错误,即使 this.x 函数已绑定
- javascript - 创建一个包含 20 个随机数的数组
- java - android CallLog中subscription_id的含义
- javascript - Uncaught In promise Dom 异常
- reactjs - 为什么反应组件状态没有更新
- html - bootstrap : onclick navbar margin-top = 10 vh;
- android - 在芯片组中设置芯片文本的问题