Inside the curly braces of _BallState
create a variable called ballNumber
that can only hold integers (int
), set it to equal 0.
Instead of hard coding the ball image name that's being displayed on screen, use the ballNumber
variable you just created instead.
When the button gets pressed, use the Random()
generator and the nextInt()
method from the dart:math library to generate a new ballNumber
between 0 - 4.
print the ballNumber to the console when the button gets pressed.
When you run the app and click on the ball image you should see random number between 0 - 4 printed in the console like this: