0

I notice that often when I write applications on flutter I am prompted to replace final with const. What is the point, why is it better to write const rather than final in such a case?

bool isSpotButton(String? status) {
final i = 2;
 if (status == "20" || status == "25") {
     return false;
 }

 return true;

}

I tried to look at the principle in different methods, but I did not understand exactly when and on what principle I was offered to replace final with const. I would like to understand the logic of this, thank you

1 Answers1

0

The fact is that we can always use final, and const only when we can tell the exact value of a variable even before compilation