Jon
Jon

Reputation: 115

Integers of values 0 to show 2 digits or decimal places - flutter

Hi there I am having trouble displaying a variable with a value of zero ith more the one place except for in the terminal.

i have 2 simple variables that I initialize at the start of my app

int players = 00 double pot = 00.00

id like my variable to be displayed on the screen like that when the app fist starts but it always reverts player to 0 and pot to 0.0

I've had no luck with doing that with the text widget it will only show 1 zero

Text(
              'Players : $players',
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25.0),
            ),
            Text(
              'Current Pot :  $pot',
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25.0),
            ),

any ideas?

Upvotes: 0

Views: 2693

Answers (1)

Asher Kach
Asher Kach

Reputation: 151

It isn't exactly clear what behavior is expected when the value of players and the value of pot changes. You are probably seeking something along the lines of players.toString().padLeft(2, '0') and pot.toStringAsFixed(2).padLeft(5, '0'). Behavior shown when these values change in DartPad.

Upvotes: 5

Related Questions