Rajat Palankar
Rajat Palankar

Reputation: 167

Flutter 2.5 update - const keyword on every static Widget

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

Upvotes: 5

Views: 1648

Answers (1)

esentis
esentis

Reputation: 4696

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.

Upvotes: 13

Related Questions