import 'package:flutter/material.dart'; import 'dart:math'; void main() { runApp(const MagicBall()); } class MagicBall extends StatefulWidget { const MagicBall({super.key}); @override State createState() => _MagicBallState(); } class _MagicBallState extends State { 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(); }); }, ), ), ); } }