I need to display text and a double in a Text widget but I am getting an error. This should be a simple thing to do.
Here is the code:
double commission = 0.0;
const Text('Commission: ${commission}'),
Here is the error
A value of type 'Null' can't be assigned to a parameter of type 'String' in a const constructor.
Try using a subtype, or removing the keyword 'const'.dartconst_constructor_param_type_mismatch
Unnecessary braces in a string interpolation.
Try removing the braces.dartunnecessary_brace_in_string_interps
Invalid constant value.dart(invalid_constant)
Nothing I try works. I initialized the variable but it still doesn’t work.
This should be easy but how do I fix it?
Thanks
2
Answers
Remove
const
because You are trying to embed dynamic value in your widget such that its content can change dynamically where you can’t useconst
.Unable to add ‘const’ with dynamic value.