diff --git a/lib/main.dart b/lib/main.dart index 6a5b495..c81c171 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,10 @@ +import 'dart:math'; import 'package:flutter/material.dart'; void main() { return runApp( MaterialApp( + debugShowCheckedModeBanner: false, home: Scaffold( backgroundColor: Colors.red, appBar: AppBar( @@ -15,36 +17,50 @@ void main() { ); } -class DicePage extends StatelessWidget { - int left = 4; - int right = 5; +class DicePage extends StatefulWidget { + @override + _DicePageState createState() => _DicePageState(); +} + +class _DicePageState extends State { + int leftDiceNumber = 1; + int rightDiceNumber = 1; + + void changeDiceFace() { + setState(() { + leftDiceNumber = Random().nextInt(6) + 1; + rightDiceNumber = Random().nextInt(6) + 1; + }); + } + @override Widget build(BuildContext context) { return Center( child: Row( children: [ Expanded( - child:TextButton( - onPressed:(){ - - }, - child: Image.asset('images/dice$left.png'), - ), + child: TextButton( + child: Image.asset( + 'images/dice$leftDiceNumber.png', ), - - - Expanded( - child:TextButton( - onPressed: (){ - + onPressed: () { + changeDiceFace(); + }, + ), + ), + //Get students to create the second die as a challenge + Expanded( + child: TextButton( + child: Image.asset( + 'images/dice$rightDiceNumber.png', + ), + onPressed: () { + changeDiceFace(); }, - child: Image.asset('images/dice$right.png'), ), ), ], ), ); } - - //void setState(Null Function() param0) {} - +} \ No newline at end of file