Skip to content

Instantly share code, notes, and snippets.

@angelabauer
Created February 15, 2019 17:38
Show Gist options
  • Save angelabauer/971116cbd90c887e5e41487521819594 to your computer and use it in GitHub Desktop.
Save angelabauer/971116cbd90c887e5e41487521819594 to your computer and use it in GitHub Desktop.
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