最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

lint - Flutter VS Code Not Showing 'const' Warning Automatically - Stack Overflow

programmeradmin1浏览0评论

Previously, VS Code would automatically show the warning:

Try adding the 'const' keyword to the constructor invocation

However, now it only appears if I explicitly add

prefer_const_constructors: true

in my analysis_options.yaml.

I want VS Code to show this warning automatically without needing to enable the rule manually in every project.

Flutter Version : 3.29.0 
Dart Version : 3.7.0

Previously, VS Code would automatically show the warning:

Try adding the 'const' keyword to the constructor invocation

However, now it only appears if I explicitly add

prefer_const_constructors: true

in my analysis_options.yaml.

I want VS Code to show this warning automatically without needing to enable the rule manually in every project.

Flutter Version : 3.29.0 
Dart Version : 3.7.0
Share Improve this question edited Mar 28 at 10:17 Munsif Ali 6,4525 gold badges25 silver badges53 bronze badges asked Mar 28 at 7:13 Akhil GeeAkhil Gee 4472 silver badges16 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 1

The const lint has been removed from flutter lints. You could check this issue https://github/dart-lang/core/issues/833 and https://github/flutter/flutter/issues/149932 or more details.

Right now, you would need to enable this lint rule in your `analysis_options.yaml` if you need it.

That has been removed by default check this issue https://github/dart-lang/core/issues/833 along with other lints like avoid_print which was enabled in flutter lints by default.

The following lints were removed in flutter_lints: 5.0.0

  • prefer_const_constructors
  • prefer_const_literals_to_create_immutables
  • prefer_const_declarations

in this PR https://github/flutter/flutter/pull/156011

if you want to enable that again add this in analysis_options.yaml

linter:
  rules:
    prefer_const_constructors: true

or you can use version lesser than 5.0.0 like flutter_lints: ^4.0.0

发布评论

评论列表(0)

  1. 暂无评论