Flutter 2.5 update - const keyword on every static Widget

Viewed 1131

After flutter 2.5 update, every widget that uses static data need to by put in const keyword

How to get ride of that warning to use const or how to auto insert const when we create widget in flutter code

enter image description here

1 Answers

This is because by default we now have the flutter_lints rules. It is a good practice to use the const keyword. However if you feel like removing it, you can edit your static_analysis.yaml file and add the following:

linter:
  rules:
    prefer_const_constructors: false

UPDATE 24/11/21

dart fix --apply can now fix prefer_const_constructors warnings.

Related