Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- },
- );
- },
- ),
- ],
- );
- }
- }
Add Comment
Please, Sign In to add comment