直到今天我还没有看到这个 dart 代码建议。我很高兴遵循最佳实践,但说实话,这在没有构造函数的有状态小部件中出现是没有意义的。我认为这可能与 @immutable 注释有关,但似乎并非如此,而且 dart 文档也没有真正的帮助。
Dart 文档
https://dart-lang.github.io/linter/lints/prefer_const_constructors.html https://dart-lang.github.io/linter/lints/prefer_const_constructors.html
VSCode 中的代码建议
Prefer const literals as parameters of constructors on @immutable classes.dart. || Prefer const with constant constructors
问题:这是我需要关心的事情还是我的插件已打开
VSCode 失控了?
代码示例,其中显示所有小部件。
Column(
children: [
Container(
margin: EdgeInsets.only(left: 20, right: 20),
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(30),
),
color: Colors.black,
),
child: Center(
child: Text(
'Create Account',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 19),
),
),
),
SizedBox(
height: 20,
)
完整性筛选