Magic 8 Ball

This commit is contained in:
2026-01-20 00:34:27 +05:30
commit de1882f245
77 changed files with 1910 additions and 0 deletions

58
lib/main.dart Normal file
View File

@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(const MagicBall());
}
class MagicBall extends StatefulWidget {
const MagicBall({super.key});
@override
State<MagicBall> createState() => _MagicBallState();
}
class _MagicBallState extends State<MagicBall> {
int prediction = 1;
int getPrediction() {
return Random().nextInt(5) + 1;
}
@override
void initState() {
super.initState();
prediction = getPrediction();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
title: Center(
child: Text(
'Ask Me Anything',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 25,
),
),
),
backgroundColor: Colors.blue.shade900,
),
body: TextButton(
child: Center(child: Image.asset('assets/ball$prediction.png')),
onPressed: () {
setState(() {
prediction = getPrediction();
});
},
),
),
);
}
}