Add files via upload

This commit is contained in:
Lakindu Widuranga Alwis 2023-01-05 13:47:32 +05:30 committed by GitHub
parent b48c96ae5f
commit 723a8c9395
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<DicePage> {
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: <Widget>[
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) {}
}