parent
5930216783
commit
a0b9ca3a3a
@ -1,5 +1,3 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
@ -17,47 +15,9 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
class DicePage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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'),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user