arrmani88
arrmani88

Reputation: 1092

How to fix all 'const' warnings in Android Studio by one action - Flutter

I have the following warnings in Android Studio's Dart Analysis window that get detected in my Flutter code.
I want to fix them all by doing only one action
Is there any approach to do this?

Note that i'm working with Android Studio Arctic Fox | 2020.3.1 Patch 2 on MacOS Mojave 10.14.6

enter image description here

Upvotes: 1

Views: 2444

Answers (4)

Sanny khan
Sanny khan

Reputation: 393

Firstly you can see all the warnings by typing in android studio terminal

dart fix --dry-run

Now if you want everything to be fixed in 1 command then write

dart fix --apply

It will fix every warning including adding const to your code where needed.

Upvotes: 0

Haramine Sinan
Haramine Sinan

Reputation: 55

Hover in const problem

after clicking on more options

Hover on any const warnings and go to more options. Then you will find to fix const warning of that particular file everywhere. Peace! ✌

Upvotes: 0

arrmani88
arrmani88

Reputation: 1092

They added a feature to the newest Android Studio versions, so we can fix all hints in the same file by one click.

enter image description here

Upvotes: 2

Salman Ahmed
Salman Ahmed

Reputation: 379

In the root dir of project, Goto => analysis_option.yaml file in the rules section add: prefer_const_constructors : false

Upvotes: -1

Related Questions