I want the calculation that I made in the function to display in text widget

Viewed 22
  int currentSitMoney = 0;
  int currentSitPercent = 0;
  void buyValue() {
    setState(() {
      int boughtValue = valueNotifier.value;
      money = money - money;
      int newValue = valueNotifier.value;
      currentSitPercent = (newValue - boughtValue) ~/ boughtValue * 100;
      currentSitMoney = (money * currentSitPercent) + money;
    });
  }

I have a parameter called random that gets random numbers between 1 to 999 included, I want to press buy and it will record the the value that was when I pressed and than calculated the profit or loss that you make and than when you sell it will calculate how much money you should be returned. now I dont know even if I did it correctly but please tell me if its correct how do I put the output in a text widget the currentSitMoney and currentSitPercent... enter image description here

1 Answers

To display a value in a widget you can do like this

Container(
   child: Text("This is currentSitMoney: ${currentSitMoney} | This is 
   currentSitPercent: ${currentSitPercent}"),
),
Related