Guest User

Untitled

a guest
Feb 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. class DicePageState extends State<DicePage> {
  2. int dice1Value = 1;
  3. int dice2Value = 2;
  4.  
  5. @override
  6. Widget build(BuildContext context) {
  7. return Column(
  8. children: <Widget>[
  9. FlatButton(
  10. child: Image(
  11. image: AssetImage('images/dice$dice1Value.png'),
  12. ),
  13. onPressed: () {
  14. setState(
  15. () {
  16. dice1Value = Random().nextInt(6) + 1;
  17. },
  18. );
  19. },
  20. ),
  21. FlatButton(
  22. child: Image(
  23. image: AssetImage('images/dice$dice2Value.png'),
  24. ),
  25. onPressed: () {
  26. setState(
  27. () {
  28. dice2Value = Random().nextInt(6) + 1;
  29. },
  30. );
  31. },
  32. ),
  33. ],
  34. );
  35. }
  36. }
Add Comment
Please, Sign In to add comment