I want to increment my price by the percentage that the user types in the UI, how do I do the math of that?
for example with simple math you do it like this
- Increase the value by 1%:
1.45 x 1.01 = 1.4645 - Decrease the value by 1%:
1.45 x 0.99 = 1.4355 - Increase the value by 10%:
1.45 x 1.10 = 1.595 - Decrease the value by 1%:
1.45 x 0.90 = 1.305
But I don’t know how to do it with flutter because the user is gonna put a value from 1 to 1000 in the percentage that he wants to add.
How to change that value to match the equation above?
>Solution :
If x is the percentage the user fills in the UI and y is the value, then you do:
(x / 100 + 1) × y
x is positive for increase and negative for decreasing percentage.