A simple dice rolling app.

This commit is contained in:
2026-01-20 00:12:37 +05:30
commit 8741bfd13f
78 changed files with 1923 additions and 0 deletions

71
lib/main.dart Normal file
View File

@@ -0,0 +1,71 @@
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
return runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.red,
appBar: AppBar(title: Text('Dicee'), backgroundColor: Colors.red),
body: DicePage(),
),
),
);
}
class DicePage extends StatefulWidget {
const DicePage({super.key});
@override
State<DicePage> createState() => _DicePageState();
}
class _DicePageState extends State<DicePage> {
int leftDie = 0;
int rightDie = 0;
int diceRoll() {
return Random().nextInt(6) + 1;
}
@override
void initState() {
super.initState();
leftDie = diceRoll();
rightDie = diceRoll();
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(16.0),
child: Center(
child: Row(
children: [
Expanded(
child: TextButton(
onPressed: () {
setState(() {
leftDie = diceRoll();
});
},
child: Image.asset('assets/dice$leftDie.png'),
),
),
Expanded(
child: TextButton(
onPressed: () {
setState(() {
rightDie = diceRoll();
});
},
child: Image.asset('assets/dice$rightDie.png'),
),
),
],
),
),
);
}
}