Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to increment or decrement my price when you do +1% or -10% in flutter

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

  1. Increase the value by 1%: 1.45 x 1.01 = 1.4645
  2. Decrease the value by 1%: 1.45 x 0.99 = 1.4355
  3. Increase the value by 10%: 1.45 x 1.10 = 1.595
  4. 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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading