Invalid Constant Value using variable as parameter

You are declaring your Text widget as a const, which requires all of its children to be const as well. If you want to fix this, you should not use a const Text widget in this case as you want to pass a non-const variable.

The reason for this is that Flutter uses the const keyword as an idicator for a widget to never rebuild as it will get evaluated at compile time and only once. Hence, every part of it has to be constant as well.

double textSize = 10.04;
// ...
child: Text('Calculate Client Fees', style: TextStyle(fontSize: textSize))

Read more about it in this article.


Don't use the const keyword if you are not using fixed values.


As @creativecreatorormaybenot said you are using const Text() which is why you have to have a const value there. You can either use

const double textSize = 10.0;

or

const textSize = 10.0;

Just like this case.

Padding(
  padding: const EdgeInsets.all(value), // this value has to be a `const` because our padding: is marked const
  child: Text("HI there"),
);


Padding(
  padding: EdgeInsets.all(10), // any double value
  child: Text("HI there"),
);