Created
February 15, 2019 17:38
-
-
Save angelabauer/971116cbd90c887e5e41487521819594 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DicePageState extends State<DicePage> { | |
int dice1Value = 1; | |
int dice2Value = 2; | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
children: <Widget>[ | |
FlatButton( | |
child: Image( | |
image: AssetImage('images/dice$dice1Value.png'), | |
), | |
onPressed: () { | |
setState( | |
() { | |
dice1Value = Random().nextInt(6) + 1; | |
}, | |
); | |
}, | |
), | |
FlatButton( | |
child: Image( | |
image: AssetImage('images/dice$dice2Value.png'), | |
), | |
onPressed: () { | |
setState( | |
() { | |
dice2Value = Random().nextInt(6) + 1; | |
}, | |
); | |
}, | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment