mirrored_repositories/code_with_flutter/magic_ball
import 'package:flutter/material.dart';
import 'dart:math';

void main() {
  runApp(
    const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: BallApp(),
    ),
  );
}

class Ball extends StatefulWidget {
  const Ball({super.key});

  @override
  State<Ball> createState() => _BallState();
}

class _BallState extends State<Ball> {
  int ballNumber = 1;
  @override
  Widget build(BuildContext context) {
    return Center(
        child: TextButton(
            onPressed: () {
              setState(() {
                ballNumber = Random().nextInt(5) + 1;
              });
            },
            child: Image.asset('images/ball$ballNumber.png')));
  }
}

class BallApp extends StatelessWidget {
  const BallApp({super.key});

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        backgroundColor: Colors.grey[700],
        appBar: AppBar(
          toolbarHeight: 80.0,
          backgroundColor: Colors.black26,
          title: const Center(
              child: Text(
            'Ask Me Anything',
            style: TextStyle(
                color: Colors.white60,
                fontWeight: FontWeight.bold,
                fontSize: 30.0),
          )),
        ),
        body: const Ball(),
      ),
    );
  }
}
