Complete code
This commit is contained in:
parent
efc000ef5c
commit
5930216783
@ -1,3 +1,5 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
@ -15,9 +17,47 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
class DicePage extends StatelessWidget {
|
||||
class DicePage extends StatefulWidget {
|
||||
@override
|
||||
State<DicePage> createState() => _DicePageState();
|
||||
}
|
||||
|
||||
class _DicePageState extends State<DicePage> {
|
||||
int leftDiceNumber = 1;
|
||||
int rightDiceNumber = 1;
|
||||
|
||||
void buttonPressed() {
|
||||
leftDiceNumber = Random().nextInt(6) + 1;
|
||||
rightDiceNumber = Random().nextInt(6) + 1;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
return Center(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
setState(buttonPressed);
|
||||
},
|
||||
child: Image.asset('images/dice$leftDiceNumber.png'),
|
||||
),
|
||||
)),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
setState(buttonPressed);
|
||||
},
|
||||
child: Image.asset('images/dice$rightDiceNumber.png'),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user