mirrored_repositories/TheAppBrewery-FlutterCourse/5.magic-8-ball
import 'package:flutter/material.dart';
import 'dart:math';

void main() => runApp(
      MaterialApp(
        debugShowCheckedModeBanner: false,
        home: BallPage(),
      ),
    );

class BallPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.orangeAccent,
      appBar: AppBar(
        elevation: 0,
        title: Text('Ask Me Anything'),
        backgroundColor: Colors.blueGrey,
      ),
      body: Ball(),
    );
  }
}

class Ball extends StatefulWidget {
  @override
  _BallState createState() => _BallState();
}

class _BallState extends State<Ball> {
  int ballNumber = 1;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: FlatButton(
        onPressed: () => setState(() {
          ballNumber = Random().nextInt(5) + 1;
        }),
        child: Image.asset(
          'images/ball$ballNumber.png',
        ),
      ),
    );
  }
}
