Add files via upload
This commit is contained in:
parent
b48c96ae5f
commit
723a8c9395
@ -1,8 +1,10 @@
|
|||||||
|
import 'dart:math';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
return runApp(
|
return runApp(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: Colors.red,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
@ -15,36 +17,50 @@ void main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DicePage extends StatelessWidget {
|
class DicePage extends StatefulWidget {
|
||||||
int left = 4;
|
@override
|
||||||
int right = 5;
|
_DicePageState createState() => _DicePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DicePageState extends State<DicePage> {
|
||||||
|
int leftDiceNumber = 1;
|
||||||
|
int rightDiceNumber = 1;
|
||||||
|
|
||||||
|
void changeDiceFace() {
|
||||||
|
setState(() {
|
||||||
|
leftDiceNumber = Random().nextInt(6) + 1;
|
||||||
|
rightDiceNumber = Random().nextInt(6) + 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child:TextButton(
|
child: TextButton(
|
||||||
onPressed:(){
|
child: Image.asset(
|
||||||
|
'images/dice$leftDiceNumber.png',
|
||||||
},
|
|
||||||
child: Image.asset('images/dice$left.png'),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
onPressed: () {
|
||||||
|
changeDiceFace();
|
||||||
Expanded(
|
},
|
||||||
child:TextButton(
|
),
|
||||||
onPressed: (){
|
),
|
||||||
|
//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) {}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user