added new file
flutterdice
This commit is contained in:
parent
3638a6940b
commit
13d440240e
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:math';
|
||||
|
||||
void main() {
|
||||
return runApp(
|
||||
@ -15,9 +16,49 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
class DicePage extends StatelessWidget {
|
||||
class DicePage extends StatefulWidget {
|
||||
@override
|
||||
_DicePageState createState() => _DicePageState();
|
||||
}
|
||||
|
||||
class _DicePageState extends State<DicePage> {
|
||||
int leftdicenumber = 1;
|
||||
int rightdicenumber = 1;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
return Center(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: FlatButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
leftdicenumber = Random().nextInt(6) + 1;
|
||||
rightdicenumber = Random().nextInt(6) + 1;
|
||||
});
|
||||
},
|
||||
child: Image.asset(
|
||||
'images/dice$leftdicenumber.png',
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FlatButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
rightdicenumber = Random().nextInt(6) + 1;
|
||||
leftdicenumber = Random().nextInt(6) + 1;
|
||||
});
|
||||
},
|
||||
child: Image.asset(
|
||||
'images/dice$rightdicenumber.png',
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user