Search code examples
flutterdartflutter-layouthardcode

hard coded values in dart


What are hard coded values and how do we use it in Dart? I need some examples with code and explanation. Thank you, God bless you new to flutter and dart


Solution

  • A hardcoded value is one that is not variable, meaning that it will always evaluate to the same thing.

    Let's say that your app is a calculator, and you want it to perform a sum, if you made the user only input the numbers to be summed like first_number and second_number, but the operator was a constant defined in your code like "+", then you can say that the operation is hardcoded, regardless of language.

    If instead you could choose from different types of operators ("+", "-", "*", "/") and then you performed a switch case where you evaluate the operator and perform a different operation on first_number and second_number accordingly, then that's dynamic.