I am just getting back into coding with Flutter, and it used to be the case that my IDE would tell me when it was better to use const constructors (I use VS Code). I haven't seen that at all in my recent projects, and when going to linter and trying to add the rule prefer_const_constructors, it says it doesn't exist.
Anybody know what might be going on?

In your analysis_options.yaml, you need to have rules: between linter: and prefer_const_constructors: true. Indentation should be as follows:
linter:
rules:
prefer_const_constructors: true
The reason you can no longer see the const lint warnings in your recent projects is because the const lint rules below were recently removed from the default lints in the flutter_lints package:
To continue using them, include them in your analysis_options.yaml file.
include: package:flutter_lints/flutter.yaml
linter:
rules:
prefer_const_constructors: true
prefer_const_declarations: true
prefer_const_literals_to_create_immutables: true
See the discussion here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With